I hate having to write meaningless tests merely to improve arbitrarily-fixed code-coverage metrics in regression suites.
(Originally posted on Advogato.)
2005-04-08
2005-04-04
SRM-236
Yet another miserable performance from yours truly. The first problem was to find out the task finally left from a set of tasks after the n-th task (assuming the list is circular) is removed and the process repeatedly applied till there is only one left. I took too much time on this one, all because of a rather silly off-by-one error. The second problem was to find the n-th smallest Hamming number given a set of factors. If X1,..,Xn are the given factors, a Hamming number is X1^P1 * ... * Xn^Pn, where Pi >= 0. For example, for 2 and 3, the Hamming numbers are 1,2,3,4,6,8,9,.... My brute-force solution was too slow and timed out for large values. I could not finish this one before the deadline and thus could not attempt the third problem.
Naturally, my rating fell yet again, but the good thing is that I'm back in Division 2 where I should at least get easier problems.
(Originally posted on Advogato.)
Naturally, my rating fell yet again, but the good thing is that I'm back in Division 2 where I should at least get easier problems.
(Originally posted on Advogato.)
Labels:
advogato diary,
programming,
topcoder
2005-03-29
Java Web Start (JDK 1.4.2_07) on Linux (Again)
I found a neater way of working around the bug in Sun's javaws
in JDK 1.4.2_07 on a Linux system running kernel 2.6.x and
glibc 2.3.3+ that I referred to in my previous blog entry - I
wrote a wrapper for waitid() that tolerates the
bogus options passed by javawsbin and calls the
real waitid() with saner options. With this code,
I am finally able to run javaws without problems. Note that
this bug seems to have been fixed by Sun in JDK 1.5.0_02.
(Originally posted on Advogato.)
in JDK 1.4.2_07 on a Linux system running kernel 2.6.x and
glibc 2.3.3+ that I referred to in my previous blog entry - I
wrote a wrapper for waitid() that tolerates the
bogus options passed by javawsbin and calls the
real waitid() with saner options. With this code,
I am finally able to run javaws without problems. Note that
this bug seems to have been fixed by Sun in JDK 1.5.0_02.
/* Quick and dirty pre-loaded DSO to make buggy javawsbin
in JDK 1.4.2_07 work on Linux with kernel 2.6.x and
glibc 2.3.4.
Compilation:
gcc -O2 -fPIC -g0 -shared -o mywait.so mywait.c
Usage (Bash):
LD_PRELOAD=/path/to/mywait.so /path/to/javaws <Launcher URL>
*/
#include <dlfcn.h>
#include <sys/wait.h>
int (*real_waitid)( idtype_t, id_t, siginfo_t *, int);
int
waitid( idtype_t idtype, id_t id, siginfo_t *infop, int options)
{
int retVal = -1;
void *handle = dlopen( "/lib/libc.so.6", RTLD_LAZY);
real_waitid = dlsym( handle, "waitid");
options = (options == 0) ? WEXITED : options;
retVal = (*real_waitid)( idtype, id, infop, options);
dlclose( handle);
return retVal;
} /* End pseudo-waitid() */
(Originally posted on Advogato.)
Labels:
advogato diary,
linux,
programming
Acrobat Reader
If you remove the utterly useless plug-ins from the Acrobat Reader installation folder, it starts up much faster.
(Originally posted on Advogato.)
(Originally posted on Advogato.)
Labels:
advogato diary,
gyaan,
pdf
Java Web Start on Linux
Due to a bug in Sun's Java Web Start executable in JDK 1.4.2_07 for Linux, I am not able to use it as-is on a system with glibc 2.3.4 and kernel 2.6.11. As should be obvious, if they had made it truly Free, I could have easily fixed the problem and moved on with my life. Since it is not, I have to either use an alternative like OpenJNLP or somehow work around this bug.
On a system where this bug does not manifest itself, I used "ps --columns 2000 -e -o "%a" | grep javaws" to grab the command line that is used by this executable to spawn the Java VM. I tried modifying this command line for my system (adjusting paths) and running it but it failed trying to download the JVM from Sun's site. After a bit of snooping around, I found out that it was looking for a file named "deployment.properties" in "$HOME/.java/.deployment" that is populated by the wrapper executable with the information on the JRE being used. So I just copied this file over from the system where stuff works and adjusted the paths. It finally worked as expected, albeit without the splash screen (which I do not regret losing at all).
(Originally posted on Advogato.)
On a system where this bug does not manifest itself, I used "ps --columns 2000 -e -o "%a" | grep javaws" to grab the command line that is used by this executable to spawn the Java VM. I tried modifying this command line for my system (adjusting paths) and running it but it failed trying to download the JVM from Sun's site. After a bit of snooping around, I found out that it was looking for a file named "deployment.properties" in "$HOME/.java/.deployment" that is populated by the wrapper executable with the information on the JRE being used. So I just copied this file over from the system where stuff works and adjusted the paths. It finally worked as expected, albeit without the splash screen (which I do not regret losing at all).
(Originally posted on Advogato.)
Labels:
advogato diary,
linux,
programming
2005-03-28
JDK API Documentation
One of the minor irritants I face while programming in Java under Linux is that there is no ready equivalent of the JDK API documentation in WinHelp format that comes in so handy while looking up a method or class. The normal HTML format JavaDocs is rather painful for such tasks.
One of the options is to use either xCHM or GnoCHM with the same CHM file that I use under Windows. However the former needs wxWidgets and the latter needs GNOME, neither of which I want to install on my PC. Besides this, I do not want to support a closed-format document format that people are struggling to understand.
It seems that there is a Java-based solution called JHelpViewer to help out with this situation and my limited testing with it indicates that it is decent and does the job to a fair extent. However, I do not like the overhead of keeping a JVM instance running on my PC just to view JavaDocs. I think a better option would be to use something like Gtk2 instead.
Does no one else find it weird that Sun does not itself ship the JDK API documentation in the JavaHelp format?
(Originally posted on Advogato.)
One of the options is to use either xCHM or GnoCHM with the same CHM file that I use under Windows. However the former needs wxWidgets and the latter needs GNOME, neither of which I want to install on my PC. Besides this, I do not want to support a closed-format document format that people are struggling to understand.
It seems that there is a Java-based solution called JHelpViewer to help out with this situation and my limited testing with it indicates that it is decent and does the job to a fair extent. However, I do not like the overhead of keeping a JVM instance running on my PC just to view JavaDocs. I think a better option would be to use something like Gtk2 instead.
Does no one else find it weird that Sun does not itself ship the JDK API documentation in the JavaHelp format?
(Originally posted on Advogato.)
Labels:
advogato diary,
programming
PDF Viewer Under Linux
Mark: Honeymoon? Congratulations!
As for Evince, my PC only has KDE and therefore I don't think I can use it. In any case, I like the way Adobe Acrobat Reader cleanly renders PDFs and I especially like the navigation and zoom controls. The last I checked, both XPDF and KPDF were rather lacking in this area.
(Originally posted on Advogato.)
As for Evince, my PC only has KDE and therefore I don't think I can use it. In any case, I like the way Adobe Acrobat Reader cleanly renders PDFs and I especially like the navigation and zoom controls. The last I checked, both XPDF and KPDF were rather lacking in this area.
(Originally posted on Advogato.)
Labels:
advogato diary,
linux,
pdf
2005-03-24
Adobe Acrobat Reader 7.0 for Linux
Acrobat Reader 7.0 isavailable for Linux, but for some reason the main download page still shows 5.0 as the last supported version for Linux. This version takes up around 93MB (!) of disc space, but feels and shows documents much better than any of the other PDF viewers for Linux that I have had a look at.
(Originally posted on Advogato.)
(Originally posted on Advogato.)
Labels:
advogato diary,
linux,
pdf
"The Five Boxing Wizards Jump Quickly"
This is much better than "the quick brown fox jumps over a lazy dog", which was the only other pangram I had known before seeing this blog entry by X guru Keith Packard. Talking of X, XFree86 released their server version 4.5.0 almost a week ago and I haven't seen references to it on any of the main nerds news sites yet. From the same blog entry by Keith, I came to know that a font designed 530 years ago still looks quite decent.
(Originally posted on Advogato.)
(Originally posted on Advogato.)
Labels:
advogato diary,
fun,
linux
2005-03-23
SRM-235
This morning I took part in my second TopCoder Single Round Match (SRM) - "SRM-235". Because of my rating from the previous match, I got to compete in Division 1 this time, which translated to tougher problems and competitors. Alas, I did pathetically in this match with my final score being zero!
Once again, the two problems that I had a chance to try out were not that difficult, but sloppy coding and muddled thinking made sure that my submissions would fail. The 300-point problem was to find out the minimum positive or negative steps needed by a stepping motor to reach any of the given target positions from a given current position. On this problem, integer overflow and underflow proved to be my undoing.
The 400-point problem was to find out the centre of gravity of a perforated rectangular sheet with rectangular holes. Here my solution just did not come close enough to the official solutions and I kept tweaking the multiplications and casts in my solution to match the results. After some time I even converted my solution over to fixed-point instead of floating-point, but it was still a bit off the mark. Such fiddling around ensured that I could not submit the solution in time, let alone attempt the 900-point problem.
My rating has dropped after this match, but still not enough to get me out of the darn Division 1. I look forward to being mauled once again in the next SRM on April 2.
(Originally posted on Advogato.)
Once again, the two problems that I had a chance to try out were not that difficult, but sloppy coding and muddled thinking made sure that my submissions would fail. The 300-point problem was to find out the minimum positive or negative steps needed by a stepping motor to reach any of the given target positions from a given current position. On this problem, integer overflow and underflow proved to be my undoing.
The 400-point problem was to find out the centre of gravity of a perforated rectangular sheet with rectangular holes. Here my solution just did not come close enough to the official solutions and I kept tweaking the multiplications and casts in my solution to match the results. After some time I even converted my solution over to fixed-point instead of floating-point, but it was still a bit off the mark. Such fiddling around ensured that I could not submit the solution in time, let alone attempt the 900-point problem.
My rating has dropped after this match, but still not enough to get me out of the darn Division 1. I look forward to being mauled once again in the next SRM on April 2.
(Originally posted on Advogato.)
Labels:
advogato diary,
programming,
topcoder
Subscribe to:
Posts (Atom)
