Archive for July, 2007

Funny Code

Thinking

Some funny code I found in the web

Check boolean condition


bool b;
b = false;
if (b == true){...}



...
if (b.toString().length() < 5){...}
...



bool b = (x > y) ? true : false;



...
if (var == true)
return true;
else if (var == false)
return false;
else
return (!false && !true);
...

Get tomorrow date


datetime GetTomorowDate(void){
sleep(86400);
return GetCurrentDate();
}

Check null values


String family = "";
HashMap map = ... ;
String fValue = (String)map.get(FAMILY_NAME);
family = (fValue != null) ? fValue : fValue;



if (file == null){
System.out.println("File " + file.getName() + " is null.");
}

Cuckoo-clock


CUCKOO=`/bin/date +%I`
while [ $CUCKOO -gt 0 ]; do
eject /dev/cdrom
cat /root/sound/cuckoo.au > /dev/dsp
eject -t /dev/cdrom
CUCKOO=$((CUCKOO-1))
done

No Comments »