Skip to main content


Showing posts from 2008

SourceForge stopped shell service and broken maven2 site deployment

According to the sourceforge notice, the access methods for project web file management have changed. The new accepted methods are: SFTP, SCP, rsync over SSH. SSH shell service is not supported anymore. When maven 2 SSH based wagon deploy site, it zip the whole site, upload zip file and unzip it with remote SSH call, which wouldn't work after SHELL service is stopped. Which means SSH wagon is broken for all projects hosted in sourceforge. Issue has been raised but not resolved. Until this issue is resolved, all site deployment to sourceforge hosted project remains broken.

Replace jconsole with command line based jmxterm

JMXTERM is a command line based interactive JMX client software. It opens a command line console and user can open connection to an MBean server, then operation against it with interactive commands. The user experience of JMXTERM is like a combination of jconsole and ftp. With JMXTERM, JMX operation doesn't have to be done in graphical environment anymore. JMXTERM project has recently release the second version 0.2, which is much more reliable and better documented than the previous version 0.1. Several serious bugs including white space in MBean name and user/password based authentication were resolved in version 0.2. Besides, version 0.2 adds the feature of listing local running Java process even if they aren't launched with jmxremote argument. Links: JMXTERM project home page Download packages Version 0.2 release note

Dark Knight, the #1 movie in IMDB

This movie tells that, A comic super hero move, a box office blockbuster movie can be appreciated in the same way God Father or The Shawshank Redemption is It doesn't take comedy to be a profitable super hero movie To be a good movie, it doesn't matter how many predecessors there are. Dark Knight is unique and unconventional. The #1 position in IMDB may turns out to be too overwhelming in the future, but it's definitely easily the best movie of year, best superhero movie and a movie should be appreciated by Oscar academy.

Reflection is expensive? Illusion!

Reflection invocation is a little bit more expensive comparing to the direct call, but it wasn't very slow and it's not slow at all now in JDK 6. It is looking up by name that takes long time. Operation 2000/11 (probably jdk 1.3.1) 2003/1 (probably jdk 1.3.1) 2004/10 (jdk1.4.2_03) 2007/2 (jdk1.6.0_b105) 100,000 regular calls 2664ms 281ms 203ms 78ms 100,000 reflection calls without lookup 4216ms 297ms 250ms 78ms 100,000 reflection calls with lookup 45505ms 938ms 562ms 203ms 1,000,000 regular calls 27840ms 2578ms 1828ms 594ms 1,000,000 reflection calls without lookup 43863ms 2782ms 2485ms 641ms 1,000,000 reflection calls with lookup 47097ms 5453ms 9343ms 1984ms 10,000,000 regular calls - 25906ms 17766ms 5063ms 10,000,000 reflection calls without lookup - 27891ms 24813ms 6141ms 10,000,000 reflection calls with lookup - 54843ms 93611ms 20093ms Link: What are the performance costs involved in Java reflection? E.g., looking up a method by name and then invoking it.

Neutual density filter and long exposure

Pictures in this album were all taken from Pier66 in Seattle, between dawn and pitch black night. Most of them were under long exposure (5~60 seconds). Some were taken with neutral density filter. For examples: P7137679 is taken in early dawn with 5s exposure, with .9 neutral density filter plus a .6 graduated neutral density filter. P7137705 is taken in late dawn with 40s exposure, with .6 neutral density filter and a polarizing filter. It was already dark at that time, lights in building is on. P7137712 and P7137721 are both 50s exposure with only a polarizing filter, they were taken in dark.

Daniel Day-Lewis, the top performance of 2007

Top 100+ performance on big screen in 2007 is Daniel Day-Lewis in " There Will Be Blood (2007/08) " Casey Affleck in " The Assassination of Jesse James by the Coward Robert Ford (2007) " Marion Cotillard in " La Vie en Rose (2007) " Carice van Houten in " Black Book (2006/07) " Anamaria Marinca in " 4 Months, 3 Weeks, 2 Days (2007) " Brad Pitt in " The Assassination of Jesse James by the Coward Robert Ford (2007) " Javier Bardem in " No Country for Old Men (2007) " Ulrich Mühe in " The Lives of Others (2006/07) " Tang Wei in " Lust, Caution (2007) " Amy Ryan in " Gone Baby Gone (2007) " Complete list...

4-states state machine for CSV parsing

Parsing CSV file is easy, it's nothing but splitting string with comma delimiter, which can be easily done in Java... The first thing came to my mind when I'm about to parse CSV file in Java is just like that. Now, reality is that following examples are all possible valid lines in a CSV file 1,Bender 2,"Bender" 3,"Bender, Bending" 4,"Ben""d""er" 5, Ben"der 6, Ben""der Line 7 might be arguable but anyway, two basic rules are If there's comma in field, use double quot to wrap field, otherwise double quot wrapper isn't required. Inside double quot, double quot is used to escape double quot. Suddenly the problem is complicated to something more than string splitting, however it can be simplified into a finite state machine with 4 states. States: 1. Ready for new field (initial state) 2. Field without double quot 3. Field with double quot 4. Escaping or end of double quot Transitions *Direction*|*Condition*|*Ac

Guess a number (Find the floor in building that breaks egg)

Question I have a integer number M in my mind, a number between 1 and N where N is a big number. Chances for M to be any integer between 1 and N are the same. A friend tries to guess this number by asking me to compare M with another number, and I'll answer "your number is bigger", "smaller" or "correct". Another constraint is, his number can be bigger than or equal to M for up to 2 times. What is the strategy to figure out M with least questions? A variation of this question is, in a N stories building, with 2 eggs, find the lowest floor from where egg breaks when it drops to ground. Example answers With only one egg, I can try the 1st floor, the 2nd, 3rd ... until the egg break. This strategy works but it's the worst. Improved answer is, try 2, 4, 6, 8...until one egg breaks. Then use the other egg figure out answer. Or, try 10, 20, 30, 40.... If egg breaks on 60, try 51, 52, 53... This is slightly better than previous answer, but might not be th