Tuesday, 22 February 2011

flac to mp3

for file in *.flac; do flac -cd "$file" | lame -h - "${file%.flac}.mp3"; done

UPDATE

I used, `-h' above. Different conversion is possible with,

for file in *.flac; do flac -cd "$file" | lame --noreplaygain -q 0 --vbr-new - "${file%.flac}.mp3"; done

vbr: automatically choose bit rate to achieve a `quality': 4 is default (0 being highest,
9 being lowest).
Turn off level adjustment for each track. I can hear clipping, thank you, and will turn the level down if required.
-q 0 : highest quality encoding.

Thursday, 27 January 2011

python image cropping ( crop )

import Image
a = Image.open('screenshot-20110127@110832.png')
b = a.crop((100, 100, 400, 400)) # left, top, right, bottom.
b.save('output.png')

or, say,

import os, Image
a = os.listdir(os.getcwd())
# List of paired elements: [[image, filename], [image, filename], ...]
b = [[Image.open(i), i] for i in a if 'screenshot' in i]
c = [[i[0].crop((400, 312, 1410, 950)), i[1]] for i in b] # crop
[i[0].save(i[1][:-3] + 'new.png') for i in c] # save with new filenames.

Friday, 21 January 2011

ramdisk

from linux screw.

mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk
sudo mount -t tmpfs -o size=2048M tmpfs /tmp/ramdisk

or, use /dev/shm

even easier.

Thursday, 25 November 2010

Tuesday, 9 November 2010

ubuntu startup scripts.

What a mess. Try this:

Copy the script into /etc/init.d

Edit it to include the following header:

#! /bin/sh
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO


Do:

$ sudo chmod +x scriptname

Run,

$ sudo update-rc.d scriptname defaults

`defaults' sets `scriptname' to run at runlevels 2,3,4,5
by creating links to the script in those levels; and
adds a link to the script to kill it at levels 0, 1, 6.

Remove the startup script via,

$ sudo update-rc.d -f scriptname remove

Correct display of aterm mutt mc finch etc

aterm displayed crappy characters with mc and mutt. This was fixed by calling them as,

$ LANG=C mutt

and

$ LANG=C mc


.bashrc now has aliases for mutt and mc as above.

Tidy up ubuntu, gnome

Ubuntu defaults to `pretty' borders, `nice' shadows and other bits of peripheral crap turned on; presumably to appeal to those using linux for prettyness rather than function.

To get rid of a few of them:

sudo apt-get install compizconfig-settings-manager

The executable is, ccsm

... and, it doesn't work. Making changes to ccsm has no effect on the display. Red herring.