Tuesday, March 11, 2008
Newsflash: Eclipse is bloody slow
What's going on here? I know Java can be slow and Eclipse uses a fair bit of memory so I'm probably swapping to disk like a king, but it still seems excessive.
Friday, March 07, 2008
more on profiling
I'm hoping I can find more higher-level optimisations over the next while, but I've gotta draw a line now and get back to adding functionality, or I'll look like quite the sap when I have to demo the current stuff to my pals.
Thursday, March 06, 2008
Eclipse, TPTP and accursed JVMTI
Hitting the "Test availability" button for the post-1.5 JRE data collectors freezes Eclipse for about 10 seconds before popping up an alert box which states "The JVMTI agent org.eclipse.tptp.jvmti is not available", with a "Show details" button which expands the dialogue to display a completely blank textbox. This is clearly bollox. Searching the web leads to forum posts advising to meddle with the "Agent Controller" and RAServer programs, but I can't find them and never needed to before.
What Eclipse needs is a lightweight, simple profiler which doesn't run into stupid problems like this. For fuck's sake, I've spent over an hour getting nowhere with this stuff. Of course this would happen now, when I'm expected to give a demo of the code (running faster than what it replaces) on Monday morning.
Results of "Test Availability":

Trying to run the profiler:

An automatic update should not break Eclipse's profiler completely. Now I've gotta go with the good old "manually insert time measurement code all over the shop" technique, which fairly sucks.
Thursday, February 28, 2008
Functional Programming in Java? No, not Scala...
The notion is attractive, but then I saw some example code:
public int calcPriceInternalIterator(List items)
{
Iterator i = items.iterator();
UnaryFunction getItemPrice =
new UnaryFunction()
{
public Object evaluate (Object obj)
{
return new Double(((SETLItem)obj).getPrice());
}
};
Constant usd100 = new Constant(new Double(100));
BinaryPredicateUnaryPredicate moreThanUSD100 = new BinaryPredicateUnaryPredicate
(new UnaryCompositeBinaryPredicate(new IsGreaterThanOrEqual(), getItemPrice, usd100));
FilteredIterator fi = new FilteredIterator(i, moreThanUSD100);
Summer addPrice = new Summer();
Algorithms.foreach(fi, addPrice);
return addPrice.getSum();
}
And then in the concluding spiel:
In this article, I've introduced two functional programming techniques that can be easily integrated into your Java development practices.
... Now come on. I have no idea what that code does, because it's an ugly, bloated mess of syntax and verbose names (not to mention simply having far too many identifiers and tokens in the first place).
Java is a round hole. Functional programming is a square peg. Without modifying the syntax of the language, trying to fit the square peg in the hole may be possible, but far, far too complicated and impractical. No sane coder would want to work with that.
Tuesday, February 26, 2008
week of doom
I slightly underestimated the distance to the petrol station, so when I got my bottle of Club Orange and stuffed it into my backpack beside the Chinese food, I sat on my bike and noticed the front tyre was completely flat. Bollox, said I.
Anyway, I didn't want to faff about trying to fix it there because that takes me an hour and I had hot food in my bag. So after a longer-than-usual uncomfortable cycle home on a flat tyre, I pulled the takeaway out to find that it had leaked all the sauce from my chow mein into my backpack, all over my rain trousers and whatnot. And bollox again, I swore.
Next morning, we spent an hour fixing the puncture (I hate the damn things. Hate.) and I headed off to DCU. Some hours later, when I returned to my bike I noticed it was flat again. No problem, probably a slow puncture elsewhere, or a semi-sticky patch.. I'll just pump it up again and ride home. However, when I took the pump to college in my bag, I neglected to take the small attachment tube which connects it to the tyre's air valve. For the third time, bollox was uttered with some frustration.
Another trip home on a flat tyre, listening to the rim grind against tarmac through the outer tyre, and I left the bike 'til morning before swapping out the cursed inner tube with another I'd pulled out months ago with only one prior patch and which seemed to need only one more. This successfully carried me to college and back, but two days later it was flat again.
I put it out of my mind and on Sunday night, watched Lost at 9pm and prepared to do some catchup piano practice at 10 and a little more on Monday morning... when at about 3 minutes to ten, the power failed... apparently only on my road, or my half of the road even. So that lasted until about 3pm the next day, which caused some trouble since the piano is an electric keyboard.
When life gives you lemons, make cake! Unless you have a poxy electric cooker and the power is out.
...On the plus side, when I opened up my Macbook which had died in its sleep during the power outage (I put it to sleep with about 20 minutes left on the battery monitor, soon after the cut), I expected it to go through a normal bootup. Instead, I saw a funny progress bar whizz for a while, before it brought up the usual unlock dialogue which appears when you're logged on and wake the machine up. So there's a point where it wakes the machine from S3 (suspend-to-RAM) sleep and puts it straight into S4 (suspend-to-disk), then powers off, on the basis that the battery is about to run out which will destroy your S3 image and you'd have to boot again. Nice.
Sunday, February 17, 2008
The joys of Sozobon C
Having been slowly inching towards doing a little coding on the Atari ST, I decided to set some (very) small, straightforward goals to actually get started doing something useful. This seems to be a pretty important tactic for me, as otherwise, I can start to get lost in the haze of all my different interests and never really get anywhere.
I started laying these out in a simple todo list following the extreme programming task card style we used at Cellusys, like so:
In progress:
todo:
* ST: Display a sprite! (IH: 2)
done:
* ST: Switch to low res and back to original. (IH: 0.5 / AH: 0.5)
* ST: Print the current colour palette. (IH: 10m / AH: 20m)
* ST: Change the background colour to green. (IH: 2 (??) / AH: 10m)
Printing the palette took a bit longer since I decided to write a number->binary (string representation) conversion function, and realised I'd forgotten some pretty basic things about C. But that's part of the fun! Note my fairly pessimistic estimate of 2 hours to display a simple sprite. It's probably a good idea to err on the side of underestimating yourself when planning stuff that is somewhat beyond your ken, even if you used to do it ten years ago. To be honest though, I'm not really sure what to try after that. A little animation I suppose? Then eventually some screen flipping and fiddling with the palette and an XBIOS sound routine. Sounds like a plan...
Wednesday, February 06, 2008
The 1 percent rule
From a Wired article on geekiness in Futurama:
Cohen refers to a One Percent Rule that guided the writing on Futurama. When they were scripting the episode "Kif Gets Knocked Up a Notch," a character claims that he painstakingly programmed a holographic simulation using "4 million lines of BASIC." One writer pointed out that 99 percent of the audience wouldn't get the reference to an old programming language. Producer-writer Eric Kaplan responded, "Fuck them!"
Cooool.
Friday, January 25, 2008
Lambda the Ultimate! Mayest thou wrap with great haste.
While reading this interesting thread about "concept [representation?] programming", I immediately became frustrated at the massively long lines which forced me to scroll left to right and back constantly.
I started to search the web for a fix, tried using Google Translate (Chinese to English) to see if it would somehow fix the problem and when this failed, took a quick look in Opera's "view" menu. There I saw the obvious solution, "Fit to width". I kind of expected this to zoom the whole page out so small that I wouldn't be able to read anything, but nope; it just forces the page layout to conform to your browser window's width, effectively forcing word-wrapping. I love Opera.
Saturday, January 12, 2008
Dude, where's my fonts?
In my case, only the All Fonts and Gaeilge libraries were left, both empty. Trying to add more fonts had no effect, until I eventually realised I had to create a new library as a workaround and add fonts to that.
This worked, although due to the aforementioned .CFUserTextEncoding problem I had to open Font Book every login before applications that used interesting fonts, or they wouldn't find any.
Just for the sake of it, I opened up a bug report with Apple, not really expecting to hear anything back. A few weeks later though, I did hear back from them, with a solution that worked:
"Look for a directory called: com.apple.ATS inside of /var/folders
Once you find it, copy this directory to another location and then remove it."
Doing this and rebooting the MacBook, I logged in again and started Font Book to find, lo and behold (drumroll and angel choir) that the User and Computer font libraries were automatically added again and all the fonts loaded back into them. BRILLIANT, thanks Apple, I totally didn't expect that. Thumbs up from me!
Friday, January 11, 2008
The middle finger of .CFUserTextEncoding
The LyX error looked like this:
LyX: Creating directory
Same as entered returned
Failed to create directory. Exiting.
And Atlantis didn't give me any error message. So, after a long time fiddling around with directory permissions, changing my group from admin to user and chowning a bit, I noticed from a dtruss log of failed and successful (by simply running as another user with sudo) runs of the affected programs that the file ~/.CFUserTextEncoding was being accessed at some point.
So I had a quick look at this file in the failure (first) and success (...second) cases:
Macintosh:~ oisin$ more .CFUserTextEncoding
39:50
Macintosh:~ oisin$ more ../yunqing/.CFUserTextEncoding
../yunqing/.CFUserTextEncoding: Permission denied
Macintosh:~ oisin$ sudo more ../yunqing/.CFUserTextEncoding
0:0
Replacing mine with 0:0 and su'ing to myself to get a new shell, I was able to run LyX and Atlantis with no problems. So, I'm not sure what this means - maybe the crash wiped out an encoding method or wrote the wrong data to that file, and when applications read from .CFUserTextEncoding they tried to look for/save their settings in the wrong place.
Confusing, but at least there's a fix.
Monday, December 24, 2007
Where did Installer go in Leopard?
Another problem is that file associations got nuked. Fair enough, I can rebuild those as I run into them... but when I tried to apply a patch to NeoOffice, I'm told:
There is no default application specified to open the document "NeoOffice-blah.pkg".
Well, that's a bit strange, so I google and find that I need to use /Applications/Utilities/Installer.app for these. Great! Or not great, because the file is MISSING. I see similar problems on forums (what would we do without them? well, without the ones with actual answers anyway), and people generally recommend the poor user to reinstall via "Archive and Install" which supposedly keeps your user files/settings.
Before I made such a serious commitment to dig myself deeper in the shite, though, I did another quick google and found that as of OS X version 10.5 "Leopard", the Installer application is now located in /System/Library/CoreServices, along with a horde of other utilities.
So to others encountering this problem, DO NOT REINSTALL before checking there. It's unlikely that the program has let itself out the back door into the night. It's probably right there, hiding under your bed.
Don't be too hasty to reinstall your OS - there's usually a reasonable fix out there... Now if I can only find my font fix...
Tuesday, November 13, 2007
C++ FQA
This very good read takes the form of responses to answers on the C++ FAQ Lite. The author makes no attempt to hide his contempt for the language, and for well-explained reasons (for example, that the C++ grammar is actually undecidable and thus parsing it can sometimes have bizarre results).
I'd recommend this to anyone caught in the popular grip of C++, rather than finding out (or being caught in denial) about the pain awaiting programmers of any level. Hint: lack of garbage collection, extreme, multi-pronged lameness of templates and not-exactly-encapsulation feature heavily.
Personally, I've been working in Java for the last while anyway, but I've promised myself I'd get into (Smart)Eiffel for a while now, which seems like a much, much simpler and unambiguous language with garbage collection, a decent string class and no poxy operator overloading, and still reasonably efficient in the general case, compared to C++. Also, the D programming language may be worth a look, which seems to have some good built-in string handling (but no multiple-inheritance. Meh?).
Friday, November 09, 2007
Backflip
Everytime I try a backward somersault or handspring, I chicken out as soon as I start to fall back... like so:
How are you supposed to override that annoying reaction?
Thursday, November 08, 2007
Mac an Leabhair... the Macbook
Another fairly large skip in blogging activity... so, as part of my scholarship funding, IRCSET allow first year research students to buy a computer and put the tab on their expenses account, to the tune of €1500. Naturally, I arranged things so the computer and components came to €1490 or so - almost a bin-packing problem, but easily approximately solved.
The Macbook, a 13" white one (why pay 200 quid just to have it in black? pfft.... that'd only absorb heat and burn your err... legs, anyway) with a 2.16ghz Core2 Duo, 2 gigs of RAM (the most I've ever had in a machine before was a sad 512 megs) and a 160 gig hard disk (for research... and anime and music... not porn. Fine, for porn - are you happy now?).
Unfortunately, it came with two problems:
- The lock the sales guy sold me over the phone, which he assured would fit my machine, didn't fit the machine. In fact, it damaged the side of the case while I tried to gently fit it to the Macbook's lock slot.
This is kind of an understandable mistake - it looked almost exactly the same as another lock that did fit, and I didn't see anything on the Apple website about which lock fits which machine. - The version of OS X, which the salesman assured me would be 10.5 "Leopard" when I specifically asked him (and the previous salesman on the phone), turned out to be 10.4 "Tiger". Not that Tiger was bad, I was still delighted with its performance compared to my Windows XP, Ubuntu XFCE/Gnome and Mandriva KDE experiences. It was ridiculously fast, smooth and yes, things "just worked", to appropriate a shitty phrase.
So, for a couple of days I tried to get in touch with the sales guy, who seemed to suddenly go on annual leave, then I eventually got on the phone with another agent in Apple Education, who, when I called her for the second time 5 minutes later, told me an install disc for Leopard was on its way and I could keep the incompatible lock for which they had already sent out a compatible replacement, both without charge.
That just leaves the slight damage on the case from the weird lock, but I'm pretty impressed by their helpfulness, especially compared to Acer, who I dealt with when one of their firmware updates killed my old laptop's flash BIOS (those useless assholes charged me over €300 to replace the entire motherboard, because they apparently have no mechanism to recover from flashing the BIOS with an image from an 'incompatible' revision of the same motherboard model. The Taiwan guys sent me a text file describing some Phoenix BIOS "bootblok" recovery procedure, but either that wasn't implemented or the Official-Acer-Repair-Shop-Off-The-Naas-Road-Dublin-12 engineers were ripping me off).
Apple.getInstance().respect++;
Wednesday, October 10, 2007
grub got your goat?
So I was left with a slightly knacked partition table and decided to burn a proper GParted livecd which also contained a program called Testdisk. This was able to rebuild the partition table (although it disturbingly seemed to think the drive had 16 heads every time I loaded it, and complained that either this setting was wrong or the disk layout was crazy until I changed it to 255... every time), but at some point I managed to overwrite the MBR as well by picking the wrong option.
Attempts to reconstruct the GRUB bootloader's MBR claimed success, but actually trying to boot from the hard disk resulted in just a cursor flashing indefinitely. No message from GRUB, even.
Eventually, I found that the instructions I'd been following didn't tell me enough and that making the bootloader was a bit more involved than just:
"root (hd0, 1)
setup (hd0)",
and certainly more difficult than just running "grub-install /dev/hda2", which wasn't at all happy.
In the end, I started copying an entry from my boot partition's old GRUB menu.lst and replacing the now-inaccurate drive references:
The final sequence of commands to fix the thing was something like this:
root@gparted:~# grub
[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> root (hd0,1)
grub> kernel /boot/vmlinuz-2.6.20-16-386 root=/dev/hda2 ro quiet splash
grub> initrd /boot/initrd.img-2.6.20-16-386
GRUB Error 16: Inconsistent filesystem structure
grub> setup (hd0)
[snip a few lines of blah followed by "success"!]
grub> quit
root@gparted:~# reboot
The "error 16" line when I tried to set up the initrd threw me, but after running e2fsck on the partition at least twice I decided it was just GRUB being a bollox and went ahead with it. GRUB's own filesystem mini-tests suggested things were okay anyway. So after rebooting everything was ok.... although once I logged in, I ran a command called "update-grub" which may be Ubuntu-specific. This seems to have incorrectly specified the root partition, but we'll see...
So anyway, try that more verbose tactic before executing GRUB's setup command, if you run into a similar problem.
Thursday, October 04, 2007
swiping a computer
Then I went back to my desk, without having to wait for someone to let me in like an orphan boy, and waiting around for someone to set my nicked (from someone who hopefully wasn't using it anymore) crappy Pentium III PC to allow network logins.
I'm going to assume that this amount of hassle, bureaucracy and poor inter-department communications is a normal thing.
Saturday, September 08, 2007
fantasy... reality. fantasy... reality.
...
"I'm devastated because I have an 8-year-old for which I now have to have an explanation," said another Los Angeles-area mother, Rosie Konkel. "She's always looked at this character as a very smart and proper young lady."
Here we have a problem. That is, these people seem unable to distinguish between the character played by an actress, and the actress herself, who has her own, (almost) private life. For example, just because the character is an unrealistically good, innocent girl does not imply that the actress playing her should be the same. That's why it's called "acting".
This seems like a fundamental division - character and actor - which should be understood by even young children, yet some adults can fail to grasp it.
I heard that an actor who played a rapist in "Fair City", the crappy soap opera, was spat at on the streets and threatened for his 'crimes'. Which is bloody ridiculous - do these people think all TV is a fly-on-the-wall recording of real life? How could they possibly fail to separate the character from the actor?
Maybe you should be forced to take an IQ test before you turn on your TV.
Friday, August 10, 2007
/etc/init.d/me status --not-too-verbose
Handily enough, one of the guys I made friends with at work introduced me to the Sportslink snooker club in Santry, so I've got a chance to practice some proper snooker and improve a little, rather than bang my head off the wall on my own.
At the moment in my fragments of spare time I'm sleeping, watching the X-Files and very slowly learning three languages (Eiffel, AutoIt v3 and Chinese). Verrrry slow....ly....
Tuesday, June 26, 2007
grid projectoring!
Good idea! I'm sure it'll be approximated in open-source form to use your standard webcam, if Pluribus turns out to be expensive...
Here's a nice shot showing the boundaries of each individual projector's display...
Monday, June 04, 2007
the vacuum of "just-finished-college"
But I still haven't really done any of it, except for starting to learn Eiffel. Anyway, I'll have to get cracking before I find a job, or I might never start on it.
Just in case anyone is interested in a (not very)proof-of-concept program where you can train the TD(λ) players against either other temporal difference learners or against random players and view the plays made in a single game, I've put up the windows/linux binaries here.