Tuesday, November 04, 2008
Saturday, October 11, 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.
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.
Tuesday, July 29, 2008
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 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:
Monday, July 21, 2008
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.
Thursday, July 17, 2008
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.
Link: What are the performance costs involved in Java reflection? E.g., looking up a method by name and then invoking it.
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.
Wednesday, April 09, 2008
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)"
Friday, April 04, 2008
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
States:
- 1,Bender
- 2,"Bender"
- 3,"Bender, Bending"
- 4,"Ben""d""er"
- 5, Ben"der
- 6, Ben""der
- 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.
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
*Direction*|*Condition*|*Action*
1->2 |not(" or ,)|Append character to buffer
1->3 |" |Nothing
2->2 |not , |append character to field
1|2|4->1 |, |Output complete field and create buffer for next field
3->3 |not " |Append character to buffer
3->4 |" |Nothing
Wednesday, January 23, 2008
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
Follow this idea, assume the first egg is tried every X stories, then the total number of attempts is:
f(X) = N/2X + X/2.
When f(x) is minimized, df(x)/dx = 0. Which means: 1 - N/(X^2) = 0, therefore X=N^(1/2).
Enhance difficulty
What if there are 3 eggs? Assume the 1st egg is tried for every y stories, seconds is tried every x stories, and y=g(x), then the total number of attempts is:
f(x) = (N/g(x) + g(x)/x + x)/2.
When f(x) is minimized, its differential expression should be 0, which means:
1 + g'(x)/x - (g(x))^2/(x^2) - N * g'(x) / (g(x) ^ 2) = 0
When g(x) = x ^ 2 and N = x ^ 3, the equation stands. Therefore the answer is N^(2/3) stories for the first egg, N^(1/3) stories for the second egg and every story for the third one.
Next question
On top of what we found, what if we also what the worse case to be as good as possible? In previous analysis, the worse cases are 2 * N^(1/2) for two eggs and 3 * N^(1/3) for 3 eggs. The average number of guess can't be improved any more, since already made the differential result 0. But with some small adjustment, the worst case can be improved dramatically.
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 the best.
Follow this idea, assume the first egg is tried every X stories, then the total number of attempts is:
f(X) = N/2X + X/2.
When f(x) is minimized, df(x)/dx = 0. Which means: 1 - N/(X^2) = 0, therefore X=N^(1/2).
Enhance difficulty
What if there are 3 eggs? Assume the 1st egg is tried for every y stories, seconds is tried every x stories, and y=g(x), then the total number of attempts is:
f(x) = (N/g(x) + g(x)/x + x)/2.
When f(x) is minimized, its differential expression should be 0, which means:
1 + g'(x)/x - (g(x))^2/(x^2) - N * g'(x) / (g(x) ^ 2) = 0
When g(x) = x ^ 2 and N = x ^ 3, the equation stands. Therefore the answer is N^(2/3) stories for the first egg, N^(1/3) stories for the second egg and every story for the third one.
Next question
On top of what we found, what if we also what the worse case to be as good as possible? In previous analysis, the worse cases are 2 * N^(1/2) for two eggs and 3 * N^(1/3) for 3 eggs. The average number of guess can't be improved any more, since already made the differential result 0. But with some small adjustment, the worst case can be improved dramatically.
Subscribe to:
Posts (Atom)