Tuesday, 23 October 2007

Sound at a equal level...

Imagine; listening to your iPod and having to adjust the stupid volume time by time, cause the songs are not equally leveled or call it normalized.

As iPod or iTunes does not give you the right tools to do it at ones, let me help you a bit -with a big thanks to the makers and maintainers of MacMP3Gain-

First of all install the lovely piece of Software MacMP3Gain, you properly know the drill, download, load, drag and drop to the Applications Folder.

Next normalize all your iTunes songs:
WARNING: Please make a backup of your iTunes directory before continue, cause this will ruin your iTunes collection if things goes wrong and as always, I am NOT responsible.

As I do not like the GUI and just want to normalize all my songs the command I use will be:

$find $HOME/Music/iTunes/iTunes\ Music -type f -exec \
/Applications/MacMP3Gain.app/Contents/Resources/aacgain -c -r -m 0 {} \;
# -c = ignore clip
# -r = radio style, level number to specific value
# -m 0 = use the default level of db 89

Now you will see all your files processed, it might take a (long) while, making your machine slow and less responsive, but it will do the job :-)

When you import a new album or song, just run the command again. It will skip songs already processed.

Thursday, 18 October 2007

Damm apple keys...

Ever wanted to use a key shortcut discribed in symbols, but does not know where to find the key on the keyboard. I did :-(

Luckaly I was able to find the symbol -> key mapping over here:


And forward Delete works like pressing Fn + Delete, as told by Apple:


Wednesday, 17 October 2007

Cryptic OpenSSL...

$ openssl pkcs12 -in rick.p12 -info  -nodes
Enter Import Password:
Can't read Password

Can't read Password, brrr something naghty, bug found?

No the reason is pretty simple, the max length of the password cannot be more then 50 characters as you can see in the source

char pass[50], macpass[50];
source: pkcs12.c

Ultimate trust of FreeBSD port system...

Do you trust your system configuration and the port system, then give the following commands a try. I have to warn you, I am not responsible for any problems caused and a proper sysadmin first tries this at a sandbox (or at home ;-) )

#install latest ports
$sudo portsnap fetch
#spot out of date ports
$sudo pkg_version -vIL=
#check whether install all ports goes fine
$sudo portupgrade -na
#stop all relevant ports, apache in my case
$sudo /usr/local/etc/rc.d/apache22 stop
#install them all
$sudo portupgrade -a
#restart any service updated, in my case apache (mind the out of date list)
$sudo /usr/local/etc/rc.d/apache22 start

When talking about FreeBSD ports you might also want to checkout the handbook about portsnap to install a small cron line to report outdated ports everyday

While installing port monitoring tools you also need portaudit to have critical port vulnerabilities reported to you

Friday, 12 October 2007

CGI whitespace...

I Just could not get rid of the stupid newlines and whitespace in front and at the back of my entry :-( Someone pointed me on a forgotten newline character, so this will do it :-)

#! /usr/bin/env python

import cgi
import cgitb; cgitb.enable()
from common import *

def process():
fields = cgi.FieldStorage()
print htmlHead()
if fields.has_key('testbox'):
print "XXX<pre>%s</pre>XXX" % fields['testbox'].value.strip('\r\n ')

print """
<form action="test.py" method="get">
<textarea name="testbox"></textarea>
<input type="submit">

print htmlFooter()
if __name__ == '__main__':

Note: the htmlHead() and htmlFooter() functions are just the value of the html head and footer code, which live in my own library common

Tuesday, 9 October 2007

Libraries and Mac OS X...

Ever wanted to build a shared library and hit a mac os x like machine, than the regular commandos:

$ gcc -c -fPIC calc_mean.c -o calc_mean.o
$ gcc -shared -Wl,-soname,libmean.so.1 -o libmean.so.1.0.1 calc_mean.o
will give you the error:
gcc -shared -Wl,-soname,libmean.so.1 -o libmean.so.1.0.1  calc_mean.o
i686-apple-darwin8-gcc-4.0.1: unrecognized option '-shared'
/usr/bin/ld: unknown flag: -soname
collect2: ld returned 1 exit status
You know why? Could those lovely things are called dynamic libraries in macworld and need the corresponding syntax ;-)

$ gcc -c -fPIC calc_mean.c -o calc_mean.o
$ gcc -dynamiclib -install_name libmean.dylib -o libmean.dylib calc_mean.o

Thanks to the example of René Nyffenegger about shared libraries in C