Archive for July 2010


Inspirational Movie FUEL

July 18th, 2010 — 6:22pm

The movie was released in 2008 but I just found this today while browsing new avaialble on Netflix.
Josh Tickell just refused to give up to make change for human and mother earth.
Thank you very much for the inspiration.

Comment » | Green Living

PostgreSQL: Dump Schema Only or Triggers Only

July 17th, 2010 — 2:59pm

I needed to extract triggers only, sequence/index only etc when we migrated database.
I received advice from postgresql General List and thought I should post exact step/script of how to accomplish this.

Open Terminal:

1. dump schema only

pg_dump -h localhost -p 5432 –username UserName –schema-only –format c –file path_to_backup.backup –schema ‘public’ db_name

2. create list of item that you want to extract
2.1. TRIGGERS only

pg_restore –list “path_to_backup.backup” | awk ‘/[0-9]*; [0-9]* [0-9]* (TRIGGER)/ { print }’ > “path_to_triggers.list”

2.2. SEQUENCE, INDEX

pg_restore –list “path_to_backup.backup” | awk ‘/[0-9]*; [0-9]* [0-9]* (SEQUENCE|INDEX)/ { print }’ > “path_to_seq.list”

3. Create SQL script from the list
3.1. TRIGGERS only

pg_restore -L path_to_triggers.list -f dest_path_triggers.sql path_to_backup.backup

3.2. SEQUENCE, INDEX

pg_restore -L path_to_seq.list -f dest_path_seq.sql path_to_backup.backup

Comment » | Bash Shell, PostgreSQL

nightly backup (pg_dump) with shell script and cron job

July 10th, 2010 — 8:00am

1. write a shell script

#!/bin/bash
#backup.sh
logfile=”/backups/logfile.log”
# Location to place backups.
backup_dir=”/backups”
touch $logfile
timeslot=`date +%y%m%d_%H%M`
databases=(“db1″ “db2″ “db3″)
# get length of an array
tLen=${#databases[@]}
for (( i=0; i<${tLen}; i++ )); do
echo “Vacuum Starting at `date` for database: ${databases[$i]} ” >> $logfile
timeinfo=`date ‘+%T %x’`
psql -c “vacuum verbose analyze” -d ${databases[$i]} -U postgres >> $logfile
echo “Vacuum completed. Backup Starting at `date` for database: ${databases[$i]} ” >> $logfile
pg_dump ${databases[$i]} -h 127.0.0.1  -U postgres | gzip > “$backup_dir/${databases[$i]}-$timeslot-backup.gz”
echo “Backup and Vacuum complete at `date` for database: ${databases[$i]} ” >> $logfile
done

2. Add an entry to crontab to execute the script above
2.1. open terminal and login as postgres: $ su – postgres
2.2. list cron job: $ crontab -l
2.3. edit cron job:
2.3.1. $ crontab -e #in terminal vi editor will open)
2.3.2. i for insert mode
2.3.3. enter entry. for instance, to run it every 1 am:

00 01 * * * path_to_backup.sh > /dev/null

2>&1
2.3.4. ESC key to exist edit mode
2.3.5. :wq to save and quit

Comment » | PostgreSQL

great moral leader are made of:

July 6th, 2010 — 2:13am

I salute the man who is going through life always helpful, knowing no fear, and to whom aggressiveness and resentment are alien.

- Albert Einstein

Leaders must be close enough to relate to others, but far enough ahead to motivate them.

- John Maxwell (a leadership expert/speaker/author who has sold over 13 million books.)

Leadership is not magnetic personality – that can just as well be a glib tongue. It is not “making friends and influencing people” – that is flattery. Leadership is lifting a person’s vision to high sights, the raising of a person’s performance to a higher standard, the building of a personality beyond its normal limitations.

- Peter Drucker (was called “Father Of Modern Management”)

Leaders aren’t born, they are made. And they are made just like anything else, through hard work. And that’s the price we’ll have to pay to achieve that goal, or any goal.

- Vincent Lombardi (an American football coach)

Ability is what you’re capable of doing. Motivation determines what you do. Attitude determines how well you do it.

- Lou Holtz ( a retired American football coach, and active sportscaster, author, and motivational speaker.)

The art of getting someone else to do something you want done because he wants to do it.

- Dwight D. Eisenhower (a five-star general in the United States Army and the 34th President of the United States, from 1953 until 1961)

Comment » | inspirational quotes

Install NetBeans 6.9 to OS X 10.5.8

July 5th, 2010 — 11:23pm

NetBeans 6.9 is a great PHP IDE and I have been pretty happy about it. Although initially, I almost gave up installing this on my MacBook Pro – After installation was done and launch the application I have encountered an error saying “Cannot run on older version of Java 6 Standard Edition.
Please install Java 6 Standard Edition or newer or use –jdkhome switch to point to its installation directory.

To solve this problem:

Application: Utilities: Java Preference >> Drag Java SE 6 to the top

If this doesn’t fix the issue try:

Terminal: type “env”. Do you see JAVA_HOME is defined? If so, is this pointing to older version? If so fixing that should resolve the issue (at least it resolved my case). Here is how I fixed:

  1. my JAVA_HOME was set to

    /Library/Java/Home

    which was simply the symlink to

    System/Library/Frameworks/ JavaVM.framework/Versions/1.5.0/Home

  2. rename the symlink to Home_old
  3. then create new symlink point to 1.6 (SE 6) as follows: ln -s

    /System/Library/Frameworks/ JavaVM.framework/Versions/1.6.0/Home /Library/Java/Home

4 comments » | PHP

Back to top