open terminal here

Marc Liyanage wrote a nice Apple Script which easily allows you to switch from the Finder to the Terminal.
Just download it here and drag the script to the upper free space in the Finder.

Clicking it results in a new Terminal window which location is the same as the Finder location.
new Finder icon

Here’s how it looks.

P.S. this works under OS X 10.6 ūüėČ

first look at javafx

Today I had my first look at javafx. Real nice but you must get used to the syntax.
After 1/2 hour of reading and 1/2 hour of modifying a nice netbeans example (original version from Michal Skvor) i end up with this. Not perfect but it has shown me how the javafx basics work.

screenshot
winner screen

screenshot

And after I read this ‘Deploy A Rich Internet Application Developed With JavaFX Technology‘ (another 10 minutes) i was able to deploy it to the web.

Start it

If you like it let me know

You can cheat by pressing ‘r’=remove single block. ‘s’=remove more ūüėČ

Source Code can be foundhere

the sudden death of a hdd

Now I’m sure, it’s been over a week and finally there is no possability to restore anything from the hard drive.
After paying around 160‚ā¨ for a new smaller main disk the AASP told me that he was not able to save any data and that the hdd even won’t show up in the disk utility.

So what’s the problem with Western Digital HDD’s ? This isn’t the first time I saw an WD disk stop working immediatly without any warnings. If it would be the hard drive of my macbook then ok, this one I carry around a lot. But my iMac is standing at the same position for over 1 1/2 years and wasn’t moved a single time.

this is a dark secret to me ?

what I’ve learned from this ……

BACKUP, daily BACKUP and another daily BACKUP

sort a hashmap, fast

Imagine you have an hash map where key is an String and value is a integer.
Now you want to sort based on the value of each entry in this hashmap in descanding order.

Here is how I do it:

List<Map.Entry<String, Integer>> list = new Vector<Map.Entry<String, Integer>>(myHashMap.entrySet());
java.util.Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
      public int compare(Map.Entry<String, Integer> e, Map.Entry<String, Integer> e1) {
          return (e.getValue().equals(e1.getValue()) ? 0 : (e.getValue() > e1.getValue() ? 1 : -1));
}}); 
 

Now the list contains the sorted entrys from hashmap ‘THashMap myHashMap<String,Integer>’.
Iterate over it or copy it back to ‘myHashMap’ if you need to.

Hope this helps …

java decompilers

Because I have no recent Backup of the big java project I was working I have to decompile the class Files that are in this jar.
I found 3 different java decompilers for mac os x.

  1. MacJAD (google for Download)
    – onyl able to open single class files
  2. JarInspector (http://www.codeland.org/)
    + can open jar files
    + correct 
    – unable to decompile the anonymous inner classes I use
    Рseems to be confused by nested catch and try blocks 
  3. JD-GUI (http://java.decompiler.free.fr/)  
    + can open jar files
    + 90% able to decompiling anonymous inner classes

A big problem all tools share is that if you have nested iterations, for/while loops they all rename the variable you iterate over to ‘i$’. So it’s possible if your code looks like this:

while(iterator.hashNext()) {
...
    for(int varA; ....){
        for(int varB; ....){.....}
    }
...
}

the decompiled code will end up looking this:

while(i$.hashNext()) {
...
    for(int i$; ....){
        for(int i$; ....){.....}
    }
...
}

which isn’t really funny …

My conclusion is that JarInspector seems to be the best but if you need the inner class support use JD-GUI for the parts of the code those are in.

iMac news

I stoped working yesterday and didn’t try this comercial diskW*** i thought that would be free.
doesn’t look good for my loved iMac, HardDrive doesn’t get detected in FireWire Target mode. Now he’s at the Apple Service provider. I hope I’ll soon get the call that most of the data could be recovered and averything will be fine ….
Meanwhile I’m trying recover the data I could save….

at least the next week I think I’ll only get a mocca cup of sleep ;(

Imac horror crash

I don’t know what’s going on. Last week my old Powerbook G4 suddenly stoped working because of some hdd error.
Today I told my 1 year old 24” iMac to shutdown and went away. When I returned it was still trying to shutdown but I couldn’t do anything except for resetting. After a reboot the horror was perfect because of this huge ? Symbol on the screen indicating that no hdd was found.
I was near crying
After running hardware test it told me there is an 4HDD/11/40000004 sata(0,0) error. ;(
Disk Utility told me that it couldn’t repair because of wrong disk permission and repair disk permission told me it couldn’t finish because of some unknown error ;(
I’ll now try to solve this with diskwarrior, tomorrow morning I’m going to buy some FireWire cable to try to rescue some of my data via target mode.
Wish me some luck, there’s too much work on it…
why is this happening, is there some kind if hardware destroying virus I’m infected with? A single person just can’t have so much bad luck

trove4j

For those who don’t know there is some nice gnu package you can use anywhere a normal HashMap is needed.

Just

import gnu.trove.THashMap;

and use it. The only thing that differs is speed and memory usage.

Currently I’m making a differential analysis for over 1800 documents. This means comparing all documents agains each other.
approx. (1800*1799)/2=1619100 comparisons. The average file size is 0.8 MB

With HashMap<String,Integer> I’ll use about 13Gig of Ram and need about 3h20min
With THashMap<String,Integer> I’ll never need more than 8 Gig and need about 2h40min

The THashMap is part of trove4j library.

It is descibed on their webpage:

“The Trove library provides high speed regular and primitive collections for Java.”

For more Infos visit their webpage at: http://trove4j.sourceforge.net/

obfuscated statistic script

if you read “sql, statistics, bash and some gnulplot” here is a obfuscated looking version of this script¬† ūüėČ

cB()
{ s=$2; a=0; while read L; do x=$(awk '{print $1}' \
<(echo $L)); [ $x -gt $s ] 2>/dev/null && [ $x -le \
$(( $s+$3 )) ] 2>/dev/null && a=$(( $a+1 )); [ $x -\
gt $(( $s + $(( 2*$3 )) )) ] 2>/dev/null && t=$(( $\
s+(2*$3) )) && diff=$(( $x-$t ))&& m=$(( 1+($diff/$\
3) )) && echo -e $s"\t"$a && a=1 && s=$(( $s+$3 )) \
&& for i in $(seq 1 $m); do [ $x -gt $s ] 2>/dev/nu\
ll && [ $x -le $(( $s+$3 )) ] 2>/dev/null && a=$(( \
$a+1 )); echo -e $s"\t0" && s=$(( $s+$3 )) && a=1; \
done; [ $x -gt $(( $s+$3 )) ] 2>/dev/null && echo -\
e $s"\t"$a && a=0 && s=$(( $s+$3 )) && [ $x -gt $s \
] 2>/dev/null && [ $x -le $(( $s+$3 )) ] && a=$(( $\
a+1 )); done < $1; echo -e $s"\t"$a; }