Monday, June 25, 2007

Back Up mysql DB with Nice date format and compression.

mysqldump --user=$DB_USER --password=$DB_PASSWD --all-databases | bzip2 > $DB_BACKUP/01/mysql-`date +%Y-%m-%d`.bz2

Monday, June 18, 2007

Vim Backreferences

%s/\(\d\d:\d\d:\d\d\)'/\1/
this will remove single trailing quote from the end of time portion of timestamp.


%s/\(\.\)\(\w\+$\)/\t\2/
will change
com.epictide.upmc.service.impl.AlertByUserSummaryServiceImp
at end of line to
com.epictide.upmc.service.impl AlertByUserSummaryServiceImp
with a tab between the package and the class.



# convert camel case to DB table name format.
# put an underscore between each lower case followed by upper case character.
:%s/\([a-z]\)\([A-Z]\)/\1_\2/g

# make all character upper case
:%s/.*/\L&/g

Wednesday, June 13, 2007

Extract single file from zip on unix

unzip

This unzips file relative to current path.
Tutorial on unzip here:
http://www.linuxjournal.com/article/1324

Friday, June 1, 2007

Distinct on more that 2 fields

select distinct USERNAME, CLIENTNAME from MYTABLE order by USERNAME asc