Thursday, June 16, 2011

Banking Idea: Verifying Personal Cheques.

When I write a cheque, I would like to be able to enter the amount and cheque number online before I give it to someone to deposit. The benefits of this is that I can deduct the amount from my balance immediately, and the bank can easily know that the check is authenticate. If the bank received a check that I didn't enter, it would trigger extra checks.

Wednesday, March 31, 2010

Compiling Cloudera CHD2 on Mac OsX

Download the src tarball.
Download patch for
HADOOP-3659.
Make sure you have MacPorts and zlib installed.
Untar hadoop-0.20.1+169.68.tar.gz
tar -xzf hadoop-0.20.1+169.68.tar.gz

Cd into hadoop-0.20.1+169.68
cd hadoop-0.20.1+169.68

Apply patch
cat HADOOP-3659.patch | patch -p0 

Rerun autoconf
(cd cd src/native/; autoconf)

Compile
ant compile-native

THE END!
This worked for me.

Thursday, March 11, 2010

What Java Compiler Compiled this class file.

I wrote a quick perl script to determine what version of javac
was used to compile a .class file.
Its pretty simple perl code, so here it is.
Save this to a file and make it executable


#!/usr/bin/perl -w
# Prints the version of the java compiler used to compile the class file.
# http://en.wikipedia.org/wiki/Class_(file_format)#File_layout_and_structure
#
use strict;

my %version = (
45 => "JDK 1.1",
46 => "JDK 1.2",
47 => "JDK 1.3",
48 => "JDK 1.4",
49 => "J2SE 5.0",
50 => "J2SE 6.0"
);


foreach my $ARG (@ARGV){
my $input = "";
open(FILE,"< $ARG") || die " Couldn't open $ARG";
read(FILE, $input,8) || die "Couldn't read 8 bytes.";
close(FILE);

my ($cafebabe,$minor,$major) = unpack("Nnn",$input);

if($cafebabe == 0xCAFEBABE){
my $compiler = $version{$major};
if(defined $compiler){
print "$ARG: Java Compiler was $compiler minor=$minor\n";
} else {
print "$ARG: Java Compiler was UNKNOWN major=$major minor=$minor\n";
}
} else {
printf "$ARG: Not a java file! Magic=%x\n",$cafebabe;
}

}