Sunday, December 13, 2009

Some algo fun

Well, I was trying to figure if a user could be given a pass code of length 40, and split in pieces for ease, I ended up dealing with numbers and so many calculations, that I finally made an algorithm and wrote it down in JS. The code is as follows:
//uses Firefox Firebug
console.clear();

var n = 1;

var s = 1202;

var m = 1;

while((s-n)/(n+1) >= 1 && n <= m) {

m = (s-n)/(n+1);

console.log('dashes = '+n);

console.log('chunksize = '+m);

console.log('----');

n++;

}

Some results to consider:

String Length

Number of dashes

Split length

3

1

1

40

0

0

41

5

6

Tuesday, December 08, 2009

Nautilus auto-mount with long disk id

Since Ubuntu 9.05, the free partitions are mounted with their disk id in Nautilus, which is not very convenient.

An easy and simple solution is to create a label for that partition, and then Nautilus mounts it with that label, making it easy for future use, and even if one formats the partition causing its id to change, setting the label will fix the problem immediately.

For ext2, ext3, and ext4, one can use e2label, and mtools for vfat partitions.

It is very convenient when one has multiple programs pointing at that same partition, and its id has changed.

References:
https://help.ubuntu.com/community/RenameUSBDrive