Monday, November 12, 2007

Move a file w/o changing timestamp using tar

tar -cf - ./filename | (cd other-directory; tar -xf -)

Not tested.

Wednesday, October 17, 2007

myisamchk notes

To speed up table repairing use large values for key buffer and sort buffer. Both values can be made very large cause only one of them is used at a time.

Eg: myisamchk --key_buffer_size=512M --sort_buffer_size=512M --read_buffer_size=8M --write_buffer_size=8M ./path/to/database/table.MYI

--sort-recover, -n

Tuesday, September 11, 2007

SCP example

from remote host to localhost
scp username@host:sourcefile targetfile

vice versa

scp sourcefile username@host:targetfile

Friday, July 20, 2007

Get events by date

select distinct date(A.TSTAMP) as DATES, count(A.TSTAMP) as HITS from EVENTS A, EPIC_CHRONICLES B where A.EVENTID = B.EVENTID group by DATES;

Runs very slowly at customer.

Wednesday, July 11, 2007

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

Friday, May 18, 2007

Add/Subtract to/from date MySQL

update EVENTS set TSTAMP=DATE_SUB(TSTAMP, interval 9 month)

Friday, April 20, 2007

MySQL DB dump

mysqldump -u root -p -c --databases epictide events quartz >> dbdump.sql