Here are instructions for setting up a simple bottle.py Python web application running on Dreamhost (shared) with virtualenv.
(more…)
General
A simple FastCGI bottle.py Python web application for Dreamhost
On August 18th, 2012 at 16:55
Permalink | Trackback | Links In |
Comments Off
Posted in General
HOWTO Create a CSV report from an Oracle query
On August 3rd, 2012 at 13:09
Permalink | Trackback | Links In |
Comments Off
Posted in General
Here’s a simple shell script that turns an Oracle query into a CSV file suitable for mailing.
(more…)
HOWTO change your password in Oracle
On July 25th, 2012 at 16:35
Permalink | Trackback | Links In |
Comments Off
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
On July 25th, 2012 at 15:53
Permalink | Trackback | Links In |
Comments Off
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
On July 25th, 2012 at 13:51
Permalink | Trackback | Links In |
Comments Off
Posted in General
These instructions assume you’re using a Debian/Ubuntu-based system.
- Create a web service/app (i.e., a Maven CXF JAX-RS archetype, or Flask/Bottle/Django, etc.)
- Install curl
sudo apt-get install curl - Install nginx
sudo apt-get install nginx-full
which should include nginx-common as a dependency. - Do not start nginx yet.
- Add the nginx load balancer configuration and mime.types to your web service project (called MyProject in the following examples)
- 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 - 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;
}
}
}
- Copy the mime.types definition file (as an alternative to copying the nginx configuration to /etc/nginx)
- Create a directory to hold your static web content (HTML pages, images, JavaScript)
mkdir MyProject/web/html - Create a placeholder HTML file in the static web content/html directory
- Set your webservice to run on the /svc URI endpoint (to match the nginx configuration)
- 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>
- 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/*
- Update the MyProject integration tests
- Build your project
cd ~/workspace/MyProject
mvn clean install - Install and start your app (under /opt, for instance)
- Start nginx as root
nginx -c /opt/Myproject/web/conf/balancer.nginx - Verify your deployment
- Check your placeholder HTML page
curl http://localhost:8100/index.html - Check your service health
curl http://localhost:8100/svc/health
- Check your placeholder HTML page
HOWTO minify JavaScript
On July 25th, 2012 at 13:32
Permalink | Trackback | Links In |
Comments Off
Posted in General
- Get a copy of jsmin.c from http://crockford.com/javascript/jsmin
- Compile jsmin with
gcc -o jsmin jsmin.c - Put jsmin in your path (i.e., under ~/bin)
- Minify JavaScript
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.
Scalability Secrets: custom content that scales
On July 15th, 2012 at 11:35
Permalink | Trackback | Links In |
Comments Off
Posted in General
Caveat: this isn’t about failover, security, or cloud computing.
Imagine you have 65 million registered users and you need to provide custom content for each (beyond “Hello, Bob”), say real time subscription content from tens of thousands of sources containing millions of posts.
Don’t try to show everything at once
You probably won’t be able to show everything to the user at once. Depending on your load and back-end systems, you may be lucky to simply let the registered user know that they have something to see.
Most of your users won’t be logged in
Most page views (at least to a homepage) won’t be on logged-in users: many will be first time users, or users who haven’t visited very often. You’ll need to hit your back-end servers with a specific ratio of total visits, something you can measure early, and use as a baseline for how many servers you need to scale.
(more…)
Query timing with SQLPlus
On June 15th, 2012 at 10:59
Permalink | Trackback | Links In |
Comments Off
Posted in General
SQL Developer is a good tool for creating queries, but you should be using SQLPlus when trying to time queries. If you don’t already have SQLPlus installed you can get it from Oracle:
You want Oracle Database 11g Release 2 Client (11.2.0.1.0) for Linux x86-64. Unizip the client in your home directory.
Make sure you have the following environment variables defined:
# these point to wherever you have Oracle installed
ORACLE_HOME=~/oracle/product/11.1.0/client_1
LD_LIBRARY_PATH=~/oracle/product/11.1.0/client_1
PATH=$PATH:~/oracle/product/11.1.0/client_1
If you plan to run PL/SQL DDL/DML scripts, you’ll also need a SQLPATH environment variable which points to a directory where you keep the scripts.
SQLPATH=~/sqlscripts
If you don’t already have your database defined in your /etc/tnsnames.ora file (assuming you’re using that path and not something under /home/oracle), you’ll need to add the following TNS configuration:
dbalias =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dbname)
)
)
To run SQLPlus against your database as a specific user, use the following command line:
sqlplus username@dbalias
Enter the password when prompted and you’ll now be at the SQL> prompt.
To get script timings, enter the PL/SQL command:
SET TIMING ON
Avoid my house tomorrow night, children,…
On October 31st, 2011 at 02:03
Permalink | Trackback | Links In |
Comments Off
Posted in General
Avoid my house tomorrow night, children, for I will not be handing out chocolate. Enjoy your organic fruit snacks!
Moo hoo ha ha!
Home-made banana bread! I underestimated…
On October 31st, 2011 at 00:53
Permalink | Trackback | Links In |
Comments Off
Posted in General
Home-made banana bread! I underestimated how much the raw dough would expand but it's still super yummy.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Aug | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
