Sunday, December 26, 2010

rsync from iTunes dir to SD card

So I'm using rsync to get music from my Mac to the SD card in my Samsung Intercept. I don't want all my music, I want to pick and choose. I'm using the following as my rsync command:

rsync -hrltvz --modify-window=1 --exclude-from=exclude-from-file

My exclude-from-file looks like this:

- *.m4p
- *.wav
- *.DS_Store
+ Blue October/***
- *

The final - * tells rsync to skip everything. The only thing that is copied over is the Blue October directory and everything under that directory. Any .m4p, .wav, and .DS_Store files are also excluded. To add a new artist for syncing I just add a line + artist/*** to the exclude file.

rsync to SD card recopying files

I was trying to rsync some iTunes music to an SD card from my Mac. All was working well but all the files were being synced each time. Turns out it's an issue with a Microsoft(FAT32) formatted card, which my Samsung Intercept has. Answer was to add --modify-window=1 as an rsync option. Solution here.

Friday, December 24, 2010

Multiline comments in bash

:<<MULTILINECOMMENT
echo "foo"
echo "bar"
this="variable"
MULTILINECOMMENT

Friday, December 10, 2010

Concatenation in PostgreSQL


Concatenate using || and string in side single quotes:

SELECT col1||' string goes here '||col2 AS msg FROM tbl WHERE col1=10

Random number generation on PostgreSQL

SELECT round(CAST (random()*10 AS numeric),2) AS rand_no;