RSS
 

Archive for the ‘Uncategorized’ Category

Google Code Jam Problem – Problem B. Baby Height – Mistake?

01 Apr

Just having a couple of training sessions on Google Code Jam problems I noticed the following.  I tried my luck with this problem: http://code.google.com/codejam/contest/2334486/dashboard#s=p1 .

I got it wrong quite a few times. Mostly because of the fact that I misread one sentence: “If the algorithm produces a range whose endpoints fall on fractional inches, your program should shrink the range until both endpoints can be expressed in whole inches.”.

I misread this and ended up using ints instead and letting truncation take care of the rounding down. However, this means that the lower end of the range should be rounded up. Admittedly, my mistake.

However!  I still couldn’t get it right after correcting my mistake.  Why?  Because I believe there is an error in the question. It also states:
“Each integer denoting feet will be at least 1 and at most 9.
Each integer denoting inches will be at least 0 and at most 11.”.

This, to me, means that we cannot have more than 9’11″.  I implemented this range, 1’0″ to 9’11″ in my program but still got “wrong” results.  I then took out the logic to enforce this limit and voila, my output succeeded!  So, obviously the question rather than my final answer is wrong.

I think it’s really bad to have a wrong question like this up.  It was frustrating for me, because I doubted my reading of the question before even thinking about the possibility of Google making such a mistake.  Sure, mistakes happen, but has no one noticed this yet?

 
 

Selling Domains

21 Apr

Because I want to concentrate on development of fewer web applications rather than incept new platforms and realize them, I decided to sell the following domains:

designingright.com
glaslampen.com
glasslamps.eu
inceptyou.com
landcafe-mulmshorn.de
open4geo.com
programmingreference.net
pyramidenlampen.de
pyramidlamps.com
pyramidlamps.net
uinstruct.net
youinstruct.net

 
 

jQuery Plugin Template

19 Apr

Here my simple and short jQuery plugin template. Hope it helps with plugin development. It has all the recommended settings (from docs.jquery.com/Plugins/Authoring):

(function($) {
    $.fn.pluginNamespace = function(method) {
        var defaults = {
                // settings here
            },
            settings = null,
            methods = {
                init: function(options) {
                    settings = $.extend(defaults, options);
                }
            };
        if ( methods[method] ) {
            return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof method === 'object' || ! method ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
        }
    };
})(jQuery);
 
 

CSS3 Knowledge to Ninja

13 Feb

Today, I attended this workshop @ webstock: http://estelle.github.com/CSS-Workshop

It was great. Great pace, great set of tips and tricks and as usual, great people and atmosphere.

Here some links that I found useful:

http://www.google.com/webfonts

http://leaverou.github.com/prefixfree/

http://lea.verou.me/css3patterns/

http://www.standardista.com/world-flags-with-css3-gradients/

http://westciv.com/tools/transforms/index.html

http://www.colorzilla.com/gradient-editor/

 
 

Useful Linux Commands

30 Jan

Mount a temporary file system in memory:

# mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk
# mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/

Read more: http://www.linuxscrew.com/2010/03/24/fastest-way-to-create-ramdisk-in-ubuntulinux/#ixzz1ktjbieMM

 
 

My VIM Settings

07 Sep
set ignorecase
set tabstop=2
set shiftwidth=2
set autoindent
set expandtab
imap <c-space> <c-x><c-o>
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

http://shang-liang.com/blog/using-vim-as-actionscript-editor/

 
 

How to backup Windows XP/7 partition with Linux (Ubuntu)

23 Aug

To backup any partition of any file system type with Linux, you can simply run the following command:

dd if=<input_partition> of=&<output_file> bs=<byte_count>

where

<input_partition>:= is the partition you want to backup (this can also be a file if you want to do the reverse). So, e.g. /dev/sda1 for the first partition on the first drive (hence a=drive 1, 1=partition 1, b=drive 2, …).

<output_file> := is the file you want to write the partition to (this can also be the output partition on restore).

<byte_count> := is the size of your file system’s clusters, normally 4096.

dd if=/dev/sda2 of=/d/sda2_partition bs=4096 #for my own reference
tar cvfz sda2_partition.tar.gz sda2_partition # own reference



You can then compress the file using a normal archiver and save a lot of space that way, because dd constructs a file as big as the partition because it reads bit by bit or 4096 bytes multiple times.