Saturday, April 3, 2010

Record high surfing speed

Can't believe my eyes but my Internet download speed is now 30.14Mbps ...




Monday, March 29, 2010

How to setup JDK on Snow Leopard

Here is how I did it ...

1. Modify /etc/profile by adding two entries as below
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
export PATH=$JAVA_HOME/bin:$PATH

2. run setJDK to change JDK version
3. source /etc/profile

Thursday, February 25, 2010

The Bloom box - green energy



My sixth sense tells me that this company is ready for prime time ... period.

Tuesday, February 23, 2010

My best budget SSD

Super Talent UltraDrive ME 128GB $308
Sequential Read Rate: 260 MB/s (max)
Sequential Write Rate: 195 MB/s (max)
NAND Flash: MLC
64MB DRAM cache
Access Time: 0.1 ms
Firmware upgradeable: Yes

OCZ Vertex Turbo 120GB SSD $365
Maximum sequential read speed up to 270 MB/s
Maximum sequential write speed up to 200 MB/s
Indilinx Barefoot controller and Samsung MLC NAND flash for maximum performance
64MB 180MHz DRAM cache for ramp up stutter-free performance
Seek Time less than 0.1 ms
Firmware upgradeable: No

NetBeans 6.9 new feature



It's nice to know that Netbeans will support OSGI in the next release (6.9), more detail can be found here ...

Monday, February 22, 2010

How to copy a file

How to copy a file

In Java 5 and 6:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
....
String orig ="file.xml";
String dest = "file.xml.bak";
InputStream in = new FileInputStream(orig);
OutputStream out = new FileOutputStream(dest);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();

In Java 7:
import java.file.io;
import org.apache.commons.io.FileUtils;
....
String orig ="file.xml";
String dest = "file.xml.bak";
File fOrig = new File(orig);
File fDest = new File(dest);
FileUtils.copyFile(fOrig, fDest);

In Groovy:
new File("/tmp/otherFile") << new File("/tmp/someFile").text
( new AntBuilder ( ) ).copy ( file : 'blah' , tofile : 'fobar' )

Reference

Sunday, February 21, 2010

Groovy tips

How to use 'split' on each line of a file:
new File("simple.tab").withReader{r->
line = r.readLine();
println "first line: $line"
r.splitEachLine("\t"){fields->
println "fields on line: $fields"
}
}

linefeed = "\n" //or "\r\n" if the user chose so
lines = new File('pathtofile').text.split("${linefeed}")