Thursday, December 18, 2008

varargs in javascript

I'm learning Javascript in my spare time. So when I learnt the possibility of using varargs in Javascript, I wanted to share it. Here we go;

You probably know how functions are defined in Javascript:

function transform(){
// write stuff to html below
document.write("transform function initiated");

It is, of course, possible to define functions with arguments such as;

function transformWithMessage(message){
document.write("transform function initiated: "+message);

Now, I'll show functions with indefinite number of arguments;

// defined similarly to a function with no argument
function transform(){
document.write("transform function initiated: ");
// arguments array holds any argument sent to transform() function
for(var i=0; i< arguments.length; i++)
document.write(arguments[i]+" ");

A call such as transform("first lock engaged", "second lock engaged") will result in an output such as transform function initiated: first lock engaged second lock engaged . Similarly, a call such as transform("first", "second", "third") will result in an output such as transform function initiated: first second third .

Sunday, December 14, 2008

tag your mp3 files

I always listen to music in mp3 format. That's not because I'm a big fan of lossy compression, but because mp3 files are really easy to obtain and have good enough quality if you're a bit picky in terms of ripping quality. So, you got mp3 through a p2p sharing application, or you ripped it yourself from your cds. You have to make sure that the id3 tags (metadata of mp3 files) are correct. I'm using a two step process that I can easily recommend. First get MusicBrainz's application and install it. The application will scan the desired folders and automatically tag mp3 files. I'm directly quoting from Wiki for giving info on MusicBrain's app.:

MusicBrainz captures information about artists, their recorded works, and the relationships between them. Recorded works entries capture at a minimum the album title, track titles, and the length of each track. These entries are maintained according to a common style guide. Recorded works can additionally store information about the release date and country, the CD disc ID, an acoustic fingerprint for each track and have an optional free-form text field or annotation attached to them.

The automatic tagging process is not perfect, but it is good enough for tagging large mp3 archives by spending little time. The bulk of work is complete.

The second step in tagging is complementary. Mp3 Tag Studio must be downloaded and installed. Then you'll use this app for fine-tuning id3 information. You can mass tag mp3s (assuming they share same artist/album information) or you can import metadata of the songs from their filename (which's not, of course, reliable). After that, id3 information of your mp3 archive will be close to flawless.