kopi house
Saturday, August 15, 2009
  I Quit
After a few days of fixing SyntaxHighlighter on my blog, I finally decide to quit fixing it, rather I think I quit using blogger. Its hard to customize the style on my blog and its hard to add widget into my blog. I was forced to revert to 'classic template' which remove all my widgets. (Damn!)

Hmm... Maybe I should look into wordpress. Ok, watch out my next post for my new blog site.
 
Wednesday, August 12, 2009
  Groovy Timer and Performance
Got a call from my good friend of mine mentioning groovy is slow in computation. Well, I had to agree with him that groovy might be slower than plain old Java classes. But i'm sure that will improve over time.

Our conversation start with him creating a simple script which loop 100,000 times performing simple mulitplication. He uses Linux for this test and it takes him around 2 min. I was surprise! Thus I did my own performance test with the follow script (Using tips from Groovy's Project Manager blog, Timing a closure in Groovy :D)


timer = { closure ->
start = System.currentTimeMillis()
closure.call()
println System.currentTimeMillis() - start
}

// define an array with value 1 to 100000
def rates = 1..100000

println 'Performing 1st Test with .times'
timer {
def a = 10
def b = 2
100000.times {idx-> a*rates[idx] }
}

println 'Performing 2nd test with for'
timer {
def a = 10
def b = 2
for(int i=0;i<100000;i++) {
a*rates[i]
}
}


For the 1st test, it took 187ms on my window machine and 2nd test took 62ms. Phew... Anyway we are going to exchange information on our finding.

Labels:

 
Friday, March 20, 2009
  Fun with Groovy
My colleague had a great idea for groovy's implementation

def list = []
while (list.size()<6) {
def num = new Random().nextInt(45)+1
if (!list.contains(num)) list << num
}
println list

This will be my most-used groovy script. :D

Labels: ,

 
Wednesday, February 18, 2009
  MacBook! Oh Yes!
Oh Yes! Oh Yes! Finally! Finally! I have got myself a MacBook! Yes! The one with the aluminum body! And the best part... is that I don't have to pay for it. Yap, its a birthday present from my lovely wife! What a lovely surprise!

Ok. First impression, is the build of the new MacBook is really solid! Second, I'm impressed with trackpad! multi-touch feature just like the iPhone. Switching between windows is so easy now. Not to mention how easy it is to scroll the web browser with just two fingers. It makes me thinking, "do I still need a mouse with this notebook?". Lastly, the new MacBook intelligently adjust the screen brightness according to your surround ambience. wow... :D

I am starting to see several sleepless nights. :P

Labels:

 
Friday, May 30, 2008
  Tech Talk: git

Last weekend I've finally spend 70 minute (while my baby is sleeping :P) watching this Tech Talk by Linus Torvalds on git. Its a very interesting talk on DVCS or Distributed Version Control System. I have yet had any hands-on on git but I have created a git repository.

With DVCS, it changes how developers collaborate and theres social implication. There are several other concerns but I won't be talking about it today. Watch the talk and you will know what I mean. Until next time, I will write more about them.

Labels:

 
Monday, May 5, 2008
  ClearCase and AccuRev


I was reading on some articles on version control server and I come across this video, a spoof of the popular Apple advertisement.

Labels:

 
Monday, December 3, 2007
  Quick file rename with Groovy
Recently I have been learning the syntax of regular expression. Now regular expression + (Groovy of course) become part of my 'toolset' for my daily computer usage. A very quick and easy demonstration of what I meant here..

Lets say you downloaded you favourite TV shows and you wish to rename all your .avi files into a standardize format.

E.g. You have the following files
D:\Heroes\Heroes.S01E12.HDTV-LOL.avi
D:\Heroes\heroes.S01E13.HDTV.XviD-FPN.avi
D:\Heroes\Heroes.S01E14.HDTV-LOL.avi

instead of renaming the file one-by-one, use the following code



def sourceFolder = 'D:\\Heroes'
new File(sourceFolder).eachFile {
def p = /[hH](eroes)\.S?0?(\d)E?(\d\d?).*/
if ( it.getName() ==~ p ) {
def s = (it.getName() =~ p).replaceFirst('H$1.S0$2E$3.avi')
println "${it.getName()}\n${it.getParent().toString()}\\${s}\n"
assert it.renameTo(new File("${it.getParent().toString()}\\${s}"))
}
}


Your files should be rename to
D:\Heroes\Heroes.S01E12.avi
D:\Heroes\Heroes.S01E13.avi
D:\Heroes\Heroes.S01E14.avi

Labels:

 

Name:

Why kopi house? The word kopi means coffee in our dialect and since Java symbolic icon is a cup of coffee, so this is why I named my blog as kopi house (Java with local favour) ; )

Archives
December 2007 / May 2008 / February 2009 / March 2009 / August 2009 /


Powered by Blogger

Subscribe to
Posts [Atom]