I’ve had a lucky streak: even with the occasional hard drive failure I haven’t had any major data loss for a long time. But tempting fate all this time has become worrisome, so a couple of days ago I signed up for an account at rsync.net, a place that charges $1.60/GB/mo for network accessible hard drive space. This solves the problems I’ve always had with using my own disks or DVDs for backup: if it isn’t automatic I won’t do it, and it had better be offsite. As a bonus, they gave me half off for being open source developer. My setup detailed after the jump.
Linuxy
I’ve been trying out a few new Linux features lately. First, kernel 2.6.20 is shipping with kvm which includes support for the new virtualization instructions on recent processors. This is great because I can use the kvm-modified version of qemu to boot other Linux or Windows XP images while in Linux. Emulating Linux is nice for debugging those kernel bugs that lockup the box, while Windows could theoretically be useful for reverse engineering drivers. Qemu also sets up a NAT transparently so you can easily use the network once you’re in the guest OS. No news to anyone that’s used vmware, but this is free, and a heckuva lot faster than all-software emulation. Pictured is my little XP-under-Linux test:
Also, I’m playing with Xgl a bit. This is the X server that’s built on top of OpenGL, providing window managers the ability to add eye candy to mundane things like dragging windows around. My laptop JustWorked with the builtin i945 graphics chip, which is interesting because glx still claims to be using the software renderer. Coupled with beryl, all of your virtual desktops get mapped to faces of a cube, so when you Ctrl-Alt-(left/right/mouse) you can rotate the cube to find the appropriate workspace. The window manager has active corners like OSX which default to exposé-like features. When you drag around windows under this thing, they have a cute little warping animation, and when you bring something to the front, the other windows become transparent. It’s still a little buggy and I’m not sure that I won’t find the eye-candy ridiculously annoying at some point, but for now it’s a cool toy. A screenshot wouldn’t do it justice, so visit youtube for demos of it by unaccountably shirtless dudes.
Work
Hrm, this evil project sounds familiar. Here’s hoping the contractors in Seattle that are implementing it aren’t hopeless idiots. /me scans work inbox… oops, too late.
I dislike Java.
Dear lazy web,
It would be nice if you could tell me a non-hacky way to do progress dialogs from within the event-dispatch thread in Swing, where all of our application logic happens to reside.
This doesn’t work:
display modal dialog
(won’t run because event thread is blocked)
start worker thread
Nor does this:
start worker thread
(race condition hiding the dialog)
display modal dialog
Joining in the event thread won’t work because it blocks updates. Using a non-modal dialog and passing the bottom-half of the rest of the event thread to the worker thread to execute at completion will work, but is obscenely messy. Or, one can spin in the beginning of the thread waiting for the modal dialog to appear to avoid the race condition, but that is still gross. One could subclass Dialog and have it also signal a condition variable once it blocks… ugh.
keelhaul handlin’ of OEM flags
Most of the pirate stuff annoys the heck out of me on talk like a pirate day (that was yesterday by the way, yarr and so forth). But Linus’ kernel announcement yesterday was priceless, though he could stand to work on his piratese.
My next kernel contribution should ship with 2.6.19, w00t.
Hello, java!
I was messing around with Java bytecode today for no particular reason. It’s a fairly simple assembly language — stack based so it takes a little getting used to but not hard for anyone who has used an HP calculator. I installed a copy of jasmin from my apt repository and got to work.
I wanted to make a “Hello, world!” that wasn’t completely obvious at first blush, so the plan of attack was to just push all the ascii codes on the stack in reverse order then call System.out.print() on them in a loop. Each iteration checks the loop count, if ok then pop the next code and print it. Here is where the bytecode verifier is a pain in the ass: apparently, the instructions must be executed each time through a loop with the same stacksize, or else you are branded an evil hacker. Very annoying. I could’ve used an array instead but that also takes a bunch of pushes and stores, so I just unrolled the loop. It works, I guess. Code after the jump.
Continue reading “Hello, java!”
Bug
Philly didn’t happen, again because of rain. I saw on their website that the game went on anyway. Bah.
My ubuntu install is doing a bit better after a week of various customizations. Now the Fn key and all of the special laptop keys do things (more than I ever had working on my Dell), and tap-to-click is going on the touchpad. I’m still having a strange problem with HAL, however, and negotiating its maze of XML config files isn’t the best. While looking for help, I saw this: Ubuntu bug #1. Silly, but I like the feedback, especially the “it’s a feature!” post.
It’s always rainy in Philadelphia
Well, because the last trip was such a success (rained out ballgame), this Saturday a few of us are heading back to Philly to cash in the raincheck. Here’s hoping we have enough time for a wiz wit (and of course to soak up all the culture that PA has to offer.)
In other news, I have a new laptop. After getting pissed at my Dell for its recent habit of turning itself off whenever it feels like it (hmm, just like my old Sony!), I picked up an Intel MacBook. Yep, my IQ points are already receding. First thoughts — OSX is pretty cool but I probably won’t use it much: better than hockey pucks but still too graphical for a real Unix user.
I installed ubuntu on the other half of the hard drive, and discovered an interesting failure mode of the use-sudo/no-root-password mindset. If you change the hostname (via vi /etc/hostname) without updating the hosts file, you’re screwed: sudo won’t work anymore so you have to boot single user mode to fix it. Ubuntu is a slightly more polished debian, but some things grate: ‘nano’ as the default text editor? Icky.
The mac keyboard needs some work. No PgUp/Dn, Caps lock is huge and frequently triggered, Backspace is called Delete. A little xmodmap and it’s not so bad though.
blocks
It can be a humbling experience to revist old code. And I’m not talking about the dynamic simulation stuff, which is obviously a hack on top of a pile of hacks. No, this week I returned to my old pal ansiconv, the program that converts text files to images of the text file, rendering it as if you had ANSI.SYS loaded and typed TYPE KOOL.ANS
at the cee colon backslash prompt. This program had achieved a modicum of success in its heyday but lately various alternatives have popped up written in languages such as C# and PHP. Being the C bigot that I am (one who writes Java for a living), I thought I would update this one great program, slap a PHP module interface on it, and unleash it upon the world.
Stylistically, the program was a mess: 2-space indentations, curly braces on the same line as the function definition, spaces (( after the )) parentheses, seemingly no rhyme or reason to naming of typedefs, and, horror of horrors, extensive use of studlyCaps. Oh, how I had strayed from the Unix flock. Even worse, I found an obvious bug in TAB character handling; a memleak or two in the error paths; infrequent to non-existent use of the static keyword; global variables aplenty, in one place documented “to ease calling into functions” (had I some phobia of struct?); and even a case of a function returning a pointer to a global variable. Take that ctime(3). All this in the space of some 2 KLOC.
The good news is, a few hours with vim and the codebase is much better: no more globals, no more leaks, no more uglyNamingConventions. I changed the build to create a library with a single entry point, which the ansiconv binary uses to work its magic. All the CGI support code was ripped out, and I wrote a small PHP module that utilizes libansiconv to do stuff on the web. Finally, I borrowed an enhancement from our friends who wrote the newer ansi converters, which is to emit 4 bits-per-pixel images when we can to reduce their size.
The other ansi converters are more full-featured, but C still wins in speed, hands down. A rough test shows ansiconv converts around 2500 ansis/minute, compared with 270 ansis/min for another popular PHP converter (both tests include the overhead of starting the PHP interpreter).
If you have no freakin clue what this post is on about, visit Doug’s great page, 16c.
Banshee
Look what I did: