Mischiefblog
I make apps for other people

Posts made on Wednesday, July 25th, 2012

HOWTO change your password in Oracle

Posted by Chris Jones
On July 25th, 2012 at 16:35

Permalink | Trackback | Links In |

Comments Off on HOWTO change your password in Oracle
Posted in General

With SQLPlus

Log into Oracle with SQLPlus.$ sqlplus user@dbname
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Apr 12 11:46:48 2010

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Enter password: <enter it here>

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> password
Changing password for USER
Old password: <old pass>
New password: <new pass>
Retype new password: <new pass>
Password changed
SQL> CTRL-D
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

With SQL Developer
To change your password in SQL Developer, log into the database in SQL Developer and execute the following statement:

alter user username identified by "newpassword" replace "oldpassword"

The quotes make the password safe for punctuation characters.

Shell scripts that make my life easier

Posted by Chris Jones
On July 25th, 2012 at 15:53

Permalink | Trackback | Links In |

Comments Off on Shell scripts that make my life easier
Posted in General

Below, a series of shell scripts that make my life easier. Don’t expect any great revelations or virtuoso bash scripting.
(more…)

HOWTO proxy with nginx

Posted by Chris Jones
On July 25th, 2012 at 13:51

Permalink | Trackback | Links In |

Comments Off on HOWTO proxy with nginx
Posted in General

These instructions assume you’re using a Debian/Ubuntu-based system.

  1. Create a web service/app (i.e., a Maven CXF JAX-RS archetype, or Flask/Bottle/Django, etc.)
  2. Install curl
    sudo apt-get install curl
  3. Install nginx
    sudo apt-get install nginx-full
    which should include nginx-common as a dependency.
  4. Do not start nginx yet.
  5. Add the nginx load balancer configuration and mime.types to your web service project (called MyProject in the following examples)
    1. Copy the mime.types definition file (as an alternative to copying the nginx configuration to /etc/nginx)
      cp /etc/nginx/mime.type ~/workspace/MyProject/web/conf
    2. Copy and modify the following load balancer/proxy configuration into MyProject/web/conf/balancer.nginx

      worker_processes 1;
          
      events {
          worker_connections 64;
          # multi_accept on;
      }
          
      http {
          upstream service-backend {
              server 127.0.0.1:9260;
              # server 127.0.0.1:8102;
              # server 127.0.0.1:8103;
              # server 127.0.0.1:8104;
          }
          
          keepalive_timeout 300 300;
          charset utf-8;
          default_type application/octet-stream;
          ignore_invalid_headers on;
          include mime.types;
          keepalive_requests 20;
          recursive_error_pages on;
          sendfile on;
          server_tokens off;
          source_charset utf-8;
          gzip on;
          gzip_static on;
          
          log_format main '$remote_addr $host $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $ssl_cipher $request_time';
          
          server {
              listen 127.0.0.1:8100;
              server_name mydesktop.domain.com mydesktop;
              add_header Cache-Control public;
              access_log /var/log/nginx/access.log main buffer=32k;
              error_log /var/log/nginx/error.log error buffer=8k;
              expires max;
              root /opt/MyProject/web/html;
          
              location /svc/ {
                  proxy_pass http://127.0.0.1:9260;
              }
          
              location / {
              
              }
          
              location /favicon.ico {
                  return 204;
              }
              }
      }
  6. Create a directory to hold your static web content (HTML pages, images, JavaScript)
    mkdir MyProject/web/html
  7. Create a placeholder HTML file in the static web content/html directory
  8. Set your webservice to run on the /svc URI endpoint (to match the nginx configuration)
    1. Update the MyProject integration tests

      <parameter name="com.domain.webservices.AppRest.url"
      type="text" desc="Example service URL">
      %<value>http://localhost:9260/MyProject/svc</value>
      </parameter>
    2. Update the MyProject/web/conf/web.xml to map the Jersey web application to “/svc/*” (or whatever is appropriate for your app)
      <servlet-mapping>
      <servlet-name>Jersey Web Application/svc/*
  9. Build your project
    cd ~/workspace/MyProject
    mvn clean install
  10. Install and start your app (under /opt, for instance)
  11. Start nginx as root
    nginx -c /opt/Myproject/web/conf/balancer.nginx
  12. Verify your deployment
    1. Check your placeholder HTML page
      curl http://localhost:8100/index.html
    2. Check your service health
      curl http://localhost:8100/svc/health

HOWTO minify JavaScript

Posted by Chris Jones
On July 25th, 2012 at 13:32

Permalink | Trackback | Links In |

Comments Off on HOWTO minify JavaScript
Posted in General
  1. Get a copy of jsmin.c from http://crockford.com/javascript/jsmin
  2. Compile jsmin with
    gcc -o jsmin jsmin.c
  3. Put jsmin in your path (i.e., under ~/bin)
  4. Minify JavaScript
  5. jsmin < input.js > output.min.js

As a best practice, when modifying third-party code rename your JavaScript file to something like filename.domain.min.js.