nix, shell, perl, php, mysql and mac os x tips and tricks

Wednesday, October 29, 2008

run X programs on your mac (say, on a parallels linux host or remotely)

Run this on the mac side:
ssh -X user@host

Thursday, October 16, 2008

Find and delete duplicate records in MYSQL

DELETE t2 from table AS t1, table AS t2 WHERE t1.field = t2.field AND t2.id < t1.id

Monday, October 13, 2008

encode mp3s on the fly

I use this to record audio programs (voice quality). This gives fairly
small files, which I like because it makes it possible to save a LOT of
sound on a cd, and I find that the quality is satisfactory for me.



Here is the command:
sox -t ossdsp -w -s -r 44100 -c 1 /dev/dsp -t raw - | lame --nores -b 16
-x -m m - $(date +"/home/david/test--%a%d%b%Y_%I-%M%p.mp3") &

Change the number 16 to something else, like 32 to get better quality.
Like this. (These examples produce mono.)
sox -t ossdsp -w -s -r 44100 -c 1 /dev/dsp -t raw - | lame -b 32 -x -m m -
$(date +"/home/david/audio-temp/--ChangeMyName--%a%d%b%Y_%I-%M%p.mp3") &
This part of the command:
$(date+"/home/david/test--%a%d%b%Y_%I-%M%p.mp3")
produces a file name with a date and time extension as part of it.



For stereo, try this:
sox -t ossdsp -w -s -r 44100 /dev/dsp -t raw - | lame -t -r -x -h -b 160
-s 22.05 -q 5 --nores --strictly-enforce-iso - $(date
+"/home/david/test_%a%d%b%Y_%I-%M%p.mp3")
or
sox -t ossdsp -w -s -r 44100 /dev/dsp -t raw - | lame -t -r -x -h -b 128
-s 22.05 -q 5 --nores --strictly-enforce-iso - $(date
+"/home/david/test_%a%d%b%Y_%I-%M%p.mp3")