Thursday, January 07, 2010

No Nokia PC Suite on the Mac? Try Gammu!

With almost every mobile device I've had, the amount of freedom to run arbitrary software (especially software you've written yourself) has been low. Obviously needlessly low, too.
I once bought a USB datacable for my old Sagem X-5 to upload ringtones and Java programs without having to upload them to a webserver and download them with the Sagem over WAP/GPRS. I got ringtones working, but it turned out that it was impossible to upload Java programs over the cable.
Why? Well, there's no apparent technical reason for it - but it works out in the operator's favour, forcing you to download (from yourself) over their very expensive data service - at that time, it cost €0.02 per kilobyte with Meteor, which works out at €20.48 per megabyte, a shocking waste of money!

Similarly, when I bought my Nokia 6230i back in 2006, I soon discovered that while it could download Java applications with no problem, it was impossible to install them via its MMC card. The JAR/JAD would appear in its filesystem browser, but it would declare it an "unrecognised format".
Nokia did, however, release a package called the Nokia PC Suite, which was a reasonably comprehensive tool for doing lots of different things with the phone, including the installing of Java programs. And it worked via data cable and Bluetooth. Great!

Except that now, I don't have a Windows PC (at least, one with Bluetooth or a data cable). And it only runs on Windows (surprise!). My Macbook has built-in Bluetooth and can send files via the built in utilities, but the same "unrecognised format" issue pops up.

So that was the end of my frustrating search, until yesterday... enter Gammu!

This open-source program comes with a host of features for working with different types of phones, including my 6230i, and I was able to upload and install a Java application to the phone with Gammu over Bluetooth, finally!
What's the catch? Well... Gammu itself is a command-line tool so installing a program looks like:

Jehannum:Downloads oisin$ gammu nokiaaddfile Application Bart1.4
[snip debug warnings]
Searching for phone folder: *********
Information: Declared JAR file size is different than real. Fixed by Gammu.
Adding "Bart" version created by Bart
Writing JAD file: 100 percent
Writing JAR file: 100 percent


And Gammu uses a textual configuration file - mine looks something like:

Jehannum:~ oisin$ cat .gammurc
[gammu]

port = 00:16:BC:xx:xx:xx
model = 6230i
connection = bluerfphonet
synchronizetime = no
logfile = /Users/oisin/gammu.log
logformat = textall
use_locking = no


The port value can be found in Apple's "Bluetooth Explorer" in Devices->Show Device Discovery (cmd-D), under your phone's name (but replace the hyphens with colons).

Also you have to build the program from source which requires installing CMake and MySQL, but these have automated installers which caused no brainache. Getting Bluetooth to work required a small fix to one of the build scripts, but this has since been fixed so the latest version should work out-of-box.

So, if you have a Mac and a phone which requires Windows-only software to install applications, try Gammu.


. o O ( Now if I could only find a simple way to upload programs of my choosing to my iPod Touch without having to jailbreak the thing or pay Apple, again :/)

Tuesday, December 29, 2009

Re: "China Blames Online Games for Drugs, Murder, Teen Pregnancy"

Reposting for posterity here a comment I made on this article in response to some guy asking "When did your children were listening to Chaikovskiy or Shopen LAST TIME?" - implying that it's a positive and appropriate step for China to dictate how the people should entertain themselves because of some cultural degeneration that has taken place in the Western world due to our poor choice in music, computer games or whatever else:

@Kolyan:

There would be no Tchaikovsky, Chopin, Scriabin, Dave Brubeck, Debussy, Yoko Kanno, Freddie Mercury or other clever and creative composers if governments decided and enforced what everybody should enjoy or create.

People DID commit murders, take drugs, get pregnant as teens and of course, piss their lives away, long before the age of digital computers. There were stupid, psychotic and unwise people among us throughout history - if you want to improve that then improve the education system (rather than making it a soulless rat-race) and improve social conditions (not least, healthy freedom of speech).

And re: family life being damaged - are you kidding? The internet has served to bring people closer together that may have otherwise grown apart. I chat to cousins, aunts and uncles on Facebook who live in other countries and who I might not otherwise see for years.

Sure, people get sucked into rubbish games and waste their lives, but this is a fault of the person, not the games (or pornography or whatever you want to blame). Perhaps without the social outlet of gaming, some of these people would end up addicted to heroin or committing suicide - what good could banning online gaming really do? At least these people have some sense of community and friendship.

China, stop micromanaging the people and trying to tell them how they should (or should not) entertain themselves. It's absolutely none of your business, and a very inappropriate step into personal liberties.

Monday, December 07, 2009

PicArt

This video forced me to leave the room and crouch in the kitchen, doubled up and crying with laughter, for about 3 minutes. Even thinking about it is threatening to set me off again...

Wednesday, December 02, 2009

Desk Topography

The general arrangement of my desk:
  • The z-axis (which passes through the gravitational centre of the earth) is ordered such that, on average, higher items are more recent. Papers at the bottom of the z-axis are sometimes partially chemically bonded with the desk. (That is to say, new shit is randomly piled upon old shit which is stuck to an eight month-old coffee stain)

  • Although the x-/y-axis positions of items are extremely noisy, there is a tendency for locality to correspond with the degree to which papers are topically related. (This means that everything is scattered all over the place, except for things that I had piled together for some unknown reason some months ago)

  • Rubbish follows a Gaussian distribution from the central boundary of a disc 10cm from the keyboard and ending at arm's reach... (This implies that the rubbish bin is slightly out of arm's reach and is thus underutilised)

Monday, November 23, 2009

IDLE & Python 2.6 escaping mishap

Here's an odd one that can catch out a newbie (well, me, at least):

x = '\x0'


Do that in the interpreter and it'll tell you "ValueError: invalid \x escape"... put it in a source file and execute it with F5 and nothing will happen, other than focus switching to the interpreter window. No message, no nothing. Had to do a binary(ish) search, commenting out the whole program minus one print statement and checking that it runs, then commenting out about half the file and homing in on the buggy line that way - I was writing a unit test which checked that the output of a particular function was a zero byte (the most trivial case of about 12 tests).

When you do it in the IDLE/Python 3.1 bundle, you get a notification as expected, but not in the 2.6 version for the Mac. Pity pygame doesn't work in Python 3 yet.

Sunday, November 15, 2009

Children as a hardware stress test

Phoned Medion because their data CD for this el cheapo car GPS system was just ejecting after ~10 seconds when I put it in my Macbook. The guy says "well it's not designed to run on Apple computers, we can't support them. You'll need to use a Windows machine."
So I says "wtf do you mean? All the computer is for, is to transfer map files from the CD onto an SD card which goes in the device. If it's not running any software on the computer then why would it matter what operating system I had?" and that was pretty much where I lost him. Figured it was some kind of completely braindead and needless copy protection that failed on OS X machines and went looking for torrents... unsuccessfully.

Then stuck in a DVD today and the same thing happened - doh! - just the disk getting pulled in, faint clicking for 10 seconds then the disk ejects. I tilt the laptop and hear something sliding about in the drive. Shit! Did some belt or mounting snap off?
Checking prices on eBay for a new 'superdrive' - cheapest is about €45 with postage, not bad but ouch, and opening the machine to swap DVD drives is a slog.
Maybe I can at least shake the broken object out of the drive and see if it's really screwed or maybe a fragment of a broken CD or something...
Hold the laptop with the DVD slot facing the floor, tap gently for 20 seconds, poke around in the slot with a playing card and what comes out?

A poxy 2c coin. Children FTWTF. Works now tho!

Sunday, November 08, 2009

Funny Chinese expression of the [arbitrary time period]


显怀 (xiǎnhuái): To look pregnant / Obviously pregnant

Thursday, October 29, 2009

An entertaining exchange between Irish Youtubers

In a video of a Garda car apparently being burnt out while the Gardaí were busy raiding a house in Limerick (I guess?), a heated and very entertaining exchange on the subject of dole spongers and caviar developed. This is the kind of ridiculous but witty banter that I'd miss if I left Ireland:

chris2009xx (2 weeks ago) +3
sound like traveller dole skangers, we have to pay for your dole which you use to buy hash then you have loads of children for the child benefit and retire at 15 and go into fas centres then when 18 comes you sponge the dole then have children and the trend continues. you scum get council houses and wreck them we pay for them to be done up then. then you claim footwear allowance and use the money to buy more hash, then we pay to feed you in prison, you even get free runners/trainer shoes there

eiregc09 (2 days ago) +1
and you know all about it dont ye while your sitting at home drinkin your glass of champaigne and eating your caviar you sound like a right fuckin guard thinkin your all posh ye fuckin ignorant stuck up cunt im not even from limerick and its none of your business anyway proctor do ye know who proctor is remember that fool out of police academy the film

richieobrien1 (2 weeks ago)
u wouldnt want to be talking bout me..im working full time since i left school at 18..ive a good job too..

gobsiter (1 week ago) +1
dealing is not a job

Tuesday, October 20, 2009

Nice latency

Tracing route to www.l.google.com [66.102.9.147]
over a maximum of 30 hops:

1 1 ms <1 ms <1 ms 136.206.48.254
2 1 ms <1 ms <1 ms 136.206.13.254
3 2 ms 1 ms 1 ms 193.1.244.37
4 1 ms 10 ms 1 ms inex.google.com [193.242.111.57]
5 1 ms 1 ms 1 ms 72.14.239.132
6 1 ms 1 ms 1 ms 72.14.232.235
7 3 ms 2 ms 2 ms 64.233.174.18
8 1 ms 2 ms 2 ms lm-in-f147.1e100.net [66.102.9.147]

Trace complete.


Pinging boards.ie [89.234.66.107] with 32 bytes of data:
Reply from 89.234.66.107: bytes=32 time=3ms TTL=60
Reply from 89.234.66.107: bytes=32 time=2ms TTL=60
Reply from 89.234.66.107: bytes=32 time=3ms TTL=60
Reply from 89.234.66.107: bytes=32 time=3ms TTL=60


...Ok, it makes no noticeable difference that latency is 20ms lower here than at home, but it looks cool!

Wednesday, September 09, 2009

Speed reading: can we significantly increase reading rate without losing comprehension?

No.

There is no quick fix, according to current scientific evidence. The popular techniques suggested by speed reading books (e.g. elimination of subvocalisation, avoiding regressions or "back-skipping" by force of will or by hiding "already read" words with card, trying to take in more words per fixation and reducing the number of fixations) all do more harm than good, either reducing comprehension, reading rate or both.

Important tip: look for peer-reviewed scientific studies on the subject before accepting the claims of commercial pseudo-scientific books. Also, study skills websites often don't do this, and can publish suggestions which are actually harmful.

Friday, August 28, 2009

Three annoying things

1. TV advertisements that say things like "eliminates up to 100% of dandruff flakes" or "up to 100% grey coverage" - typically ads for shampoo and the like.
Like, I can defeat up to 100% of ninjas by doing nothing, since "up to 100% of ninjas" means "x ninjas, where 0 <= x <= the total number of ninjas". A building could be up to 100% demolished by throwing a large rock at it, which is to say that it will be only very slightly damaged. Saying that a shampoo removes "up to" 100% of dandruff is saying nothing.
Stupid wishy-washy meaningless-statement-making assholes.

2. People who stand at a pedestrian crossing but don't hit the button, presumably on the assumption that they will automatically get a green light and the button does nothing but tell them to wait for the scheduled light change which would have happened anyway (which is only sometimes the case).

There are some crossroads where the pattern is like:
(A) west turning south cars only (and pedestrians crossing between NW/NE or NE/SE if the button was hit in the previous A, B or C),
(B) east and west cars only,
(C) north and south cars only.

If a pedestrian hits the light switch on the northwest, northeast or southeast corner, then they can cross at the next A.
What happens about 20% of the time, is that one or two plonkers stand at one of the lights and wait until A, upon which they still don't get a signal to cross because they never hit the button. Then they frown in confusion and eventually jaywalk at the next opportunity, cursing the system. Or you arrive at the crossing, mash the button and grimace at them, having watched them stand there like a muppet for about 30 seconds and miss the crossing timeslot.
Dumb. If you're standing in front of the button, just fucking hit it.

3. People who cross a road and casually hit the button as they walk past, even though they're not going to wait for a crossing signal. Instead, cars and cyclists have to stop and wait uselessly for nobody to cross, since the guy who hit the button is already out of sight, back on the pavement.
If you're going to just cross the road anyway, DON'T hit the fucking button!

Thursday, August 20, 2009

Software patents: broad, stifling and unfair

(posted comment on ZDNet article "Examine the patent that made selling Microsoft Word a crime")

The problem with patenting processes or algorithms - not necessarily even in computer software - is that we end up with extremely broad or obvious patents whose sole purpose is to allow the patent holder to eventually sue large companies and get (obscenely) rich, and not to safeguard investment in new inventions and products as was originally intended.

If you write a program using simple common sense and happen to "re-invent" something that's patented, that's a strong hint that the patent is too general or obvious.

This is why we have ridiculous patents on "not having to click on a control for it to display dynamic content in a web browser" (Eolas), or "method of swinging on a swing" (United States Patent 6368227, which in itself should be evidence that the US patent system needs to be destroyed and rebuilt by people with an IQ above 30).

What's next? "A method of lifting heavy objects by using one's legs, not one's back"? Or, following Eolas's lead, "not having to say 'abracadabra' and turn around three times before turning on a computer"?
And how is $280m a reasonable amount of "damages", when i4i has produced nothing that could be damaged? Where is their competing product which is suffering in the marketplace due to competition with the patent-infringing Office?

And to those arguing that Microsoft/everyone should do their "due diligence" by researching patents, have you ever written a computer program? Can you really imagine searching for patents that might cover every single aspect of the code you're writing?
Programmers produce code that solves the problems at hand. They do not think "hmm, maybe what we need is to store some text separately to where the formatting information for that text is stored. That makes sense. Better check if that is software-patented!"
Imagine trying to speak to someone while having to look up every individual word you use to check that it's not in some arbitrary blacklist. It would be an unproductive nightmare.
And on top of that, patent search is extremely difficult because they're often worded in an inconsistent, generic or confusing way.

Software patents do nothing good for anybody other than patent trolls and lawyers. For everyone else in the world, they only hold back science and progress. Get rid of software patents in the US now, and keep them out of the EU too.

Wednesday, August 19, 2009

OS X panics

A recent kernel panic on my Macbook looks quite familiar - I think it's been happening now and then since I got the machine in late 2007. This time, and probably most of the other times, it was showing video on Youtube, which suggests there might be a bug in the video driver (or err... the video card :/), but there's not much information to base a confident guess on.

The crash report looks like:
Tue Aug 18 17:58:36 2009
panic(cpu 1 caller 0x00194B15): "pmap_flush_tlbs() timeout: "
"cpu(s) failing to respond to interrupts, pmap=0x46c7ae0 cpus_to_respond=0x1"
@/SourceCache/xnu/xnu-1228.12.14/osfmk/i386/pmap.c:4582
Backtrace (CPU 1), Frame : Return Address (4 potential args on stack)
0x343f3be8 : 0x12b4c6 (0x45ec20 0x343f3c1c 0x13355c 0x0)
0x343f3c38 : 0x194b15 (0x465018 0x46c7ae0 0x1 0x195234)
0x343f3ca8 : 0x197eb4 (0x46c7ae0 0x26b46000 0x0 0x0)
0x343f3d88 : 0x16087d (0x46c7ae0 0x26b46000 0x0 0x71f9)
0x343f3de8 : 0x163170 (0x1c67c40 0x46c7ae0 0x26b46000 0x0)
0x343f3f58 : 0x1ab39c (0x4f7983c 0x26b46000 0x0 0x3)
0x343f3fc8 : 0x1a15fd (0x68b8900 0x0 0x1a40b5 0x68b8900)
No mapping exists for frame pointer
Backtrace terminated-invalid frame pointer 0xbfff7e88

BSD process name corresponding to current thread: firefox-bin

Mac OS version:
9J61

Kernel version:
Darwin Kernel Version 9.7.0: Tue Mar 31 22:52:17 PDT 2009;
root:xnu-1228.12.14~1/RELEASE_I386
System model name: MacBook2,1 (Mac-F4208CAA)

System uptime in nanoseconds: 810215756731744


A quick Google turned up mostly useless assertions on forums like "it's probably a faulty logic board or memory stick - reboot into single user mode and run memtest". In my experience, when memory goes bad, it's much more impressive than an occasional (something like once every month or two) panic. Searching a bit more carefully, I turned up some kernel source code released by Apple (cool!):

xnu-1228/osfmk/i386/pmap.c -> pmap_flush_tlbs(...)

if (cpus_to_signal) {
deadline = mach_absolute_time() + LockTimeOut;
/*
* Wait for those other cpus to acknowledge
*/
for (cpu = 0, cpu_bit = 1; cpu < real_ncpus; cpu++, cpu_bit <<= 1) {
while ((cpus_to_signal & cpu_bit) != 0) {
if (!cpu_datap(cpu)->cpu_running ||
cpu_datap(cpu)->cpu_tlb_invalid == FALSE ||
!CPU_CR3_IS_ACTIVE(cpu)) {
cpus_to_signal &= ~cpu_bit;
break;
}
if (mach_absolute_time() > deadline) {
force_immediate_debugger_NMI = TRUE;
panic("pmap_flush_tlbs() timeout: "
"cpu %d failing to respond to interrupts, pmap=%p cpus_to_signal=%lx",
cpu, pmap, cpus_to_signal);
}
cpu_pause();
}
if (cpus_to_signal == 0)
break;
}
}


I won't make any pretense at understanding most of this, but it looks like, for that panic to occur, the condition (!cpu_datap(cpu)->cpu_running || cpu_datap(cpu)->cpu_tlb_invalid == FALSE || !CPU_CR3_IS_ACTIVE(cpu)) is never met, so we keep waiting and checking until our deadline passes.
The timeout appears to be 12500000 mach time units, which apparently are equivalent to nanoseconds on my laptop - so 0.0125s, or 1/80th of a second.

So if we revisit that condition, we can assume that we get to a stage where, for at least 1/80th of a second, the inverse of the test is always true (or happens to be, every time it's checked - could be a race condition I suppose?): (cpu_running && cpu_tlb_invalid && CPU_CR3_IS_ACTIVE(cpu))...

I'm too lazy to look up what CPU_CR3_IS_ACTIVE(cpu) (a macro that expands to ("(cpu_datap(cpu)->cpu_active_cr3 & 1) == 0)") signifies, but the whole CR3 mess is some kind of i386 control register for dealing with virtual memory paging. Beyond these most basic observations, I'm pretty clueless about the problem, so would love to hear from anyone if you have any ideas.

Monday, May 18, 2009

Torrenting on the Mac

After a few years of using Azureus (or Vuze now) without major problems other than kind of large CPU and especially RAM usage, a friend suggested I give µTorrent a try since they now have Mac builds. I did, and after the first two builds which suffered from a CPU hogging bug, was surprised to find version 0.9.1.2 running smoothly for a couple of days, using about 2-5% CPU and 22MB of RAM with DHT, Peer Exchange and outgoing encryption enabled (before switching these on, it was taking about 0.6% CPU!).

That's pretty impressive IMO - previous BT clients I'd tried (Tomato, Transmission and the built in one in the Opera web browser) either seemed a bit cut-down and/or just didn't seem to download at the same speeds Azureus had achieved. So far µTorrent has worked very quickly, and has the further benefit for me of reliably working with pasted torrent URLs - Azureus almost always times out when downloading .torrent files via HTTP (no idea why; maybe a Java thing, but it happened on both my Mac and Linux boxes).

The only cons so far are that it's not open source, and that there's no Linux build... but I don't use my Linux box these days anyway. Give it a try if you're exploring BT clients on the Mac!

Friday, April 24, 2009

media filler: 'offensive' Baby Shaker

(see CNN article)
The 'Baby Shaker' app is about as stupid as the 'controversy' over such a meaningless little thing.

Typical media nonsense... 'outcry' from politically correct whingers, so what? There are always people who will get offended at something.
It's equivalent to a teenager's poorly-scrawled graffiti - offensive to anyone who WANTS to get offended, but otherwise completely trivial.

There are people being tortured and murdered, drink drivers doing hit'n'runs out there, and THIS is what makes the news? That's just silly.

Also silly is that Apple (and others in similar 'outcry' situations, like Youtube) respond so quickly and arbitrarily to take down applications like this. Not specifically in this case, because it is clearly a stupid and tasteless program, but in general when hosting providers like Youtube, Apple and some web hosts receive complaints about the 'offensive nature' of some content and they immediately (and perhaps without discussion with the author) take down the content - again, there are always going to be people out there who like to get offended at anything.
What it boils down to is that sometimes free expression suffers due to politically correct or simply malevolent, loud complainers.
Indeed, in probably all hosting provider contracts, they specifically assert the right to delete any content deemed offensive. How can this work, though, if offensiveness is in the eye of the beholder, which it most certainly is?

Friday, March 06, 2009

Lexmark X4550 wireless woes with OS X, part DEUX

The Mac drivers for the Lexmark X4550 (listed as '3500-4500 series') are a little twitchy in that, after not using the printer/scanner for a while via its wireless interface (e.g. after the wireless router has restarted), it will no longer connect to the Mac to scan nor will the Mac connect to it to print. The typical case when trying to scan and upload to a computer on the network is that the printer will display "Downloading application list" on the LCD panel after you select the desired computer to scan to, and then after about a minute, "Cannot retrieve application list".

Anyway, the scabby workaround for me is a little script which simply kills and restarts a pair of Lexmark driver services:

$ cat ~/bin/restart-lexmark-x4550.sh

killall LexmarkNetworkServices
killall "3500-4500 Series Button Monitor"
open "/Library/Application Support/Lexmark/LexmarkNetworkServices.app/"
open "/Library/Application Support/Lexmark/3500-4500 Series Scanner.bundle/Contents/SharedSupport/3500-4500 Series Button Monitor.app/"


This seems to do the trick. Of course, it would be better if Lexmark would fix their drivers, but after the last phone calls I had with their tech support I don't think this is a big priority for them (it was an outsourced-to-India tech support line, where the guy did almost everything he could to pronounce that it was a problem with my router or my computer or something, rather than actually passing on information about a probable bug to the dev team... although he did seem to have a decent technical grasp of the troubleshooting steps he performed which makes him infinitely better than the Acer helpline which appears to go to a call centre in Scotland with lots of ignorant people in it. Whoops, my comment in parentheses is longer than the preceding paragraph, boo!).

Monday, February 16, 2009

Human logic is creativity

From The Society of Mind, Marvin Minsky's excellent book (Picador edition, p. 189):
I do not mean to say that there is anything wrong with logic; I only object to the assumption that ordinary reasoning is largely based on it. What, then, are the functions of logic? It rarely helps us get a new idea, but it often helps us to detect the weaknesses in old ideas. Sometimes it also helps us clarify our thoughts by refining messy networks into simpler chains. Thus, once we find a way to solve a certain problem, logical analysis can help us find the most essential steps. Then it becomes easier to explain what we've discovered to other people - and, also, we often benefit from explaining our ideas to ourselves. This is because, more often than not, instead of explaining what we actually did, we come up with a new formulation. Paradoxically, the moments in which we think we're being logical and methodical can be just the times at which we're most creative and original.

I think the last two sentences are enlightening and in strong contrast to the popular assumptions that "logical" thinking is an antithesis of creative thinking.

Monday, February 02, 2009

Chinese text input on OS X: ITABC vs FIT

After growing somewhat accustomed to (the disappointment of) the ITABC Pinyin Chinese input method that comes with OS X, I configured my Vista work box to add the MS Pinyin input method which I soon discovered was far superior to Apple's ITABC. Partly this is due to some crasher bugs in ITABC (which I've reported and never heard back about, so maybe it only happens on my Mac?) - for example, typing any string with "shish" in it will cause part of it to crash, so that SCIM must be manually killed to force the input method system to restart before Chinese can be typed again.
More importantly however, it's just so much easier to type in the input method for Windows. I can type a full sentence and, often enough, the whole thing will be interpreted as I intended, or the small number of corrections can be elegantly entered without deleting interceding correct characters. In the Apple ITABC method, it has a strange heuristic of trying to forcibly group pairs of characters at a time, even when two single characters are much more likely. This results in an erroneous offset which often propagates all the way through the sentence so that in practice one ends up correcting the input method every character or two (by hitting space and selecting the correct match) and/or accepting then going back and correcting input manually. Not only this, but some words like 儿 completely throw off the parser - if you type 'dianer' the result is '嗲呢日' (dia3 ne ri4) rather than the obvious '点儿'.

After using the Microsoft Pinyin IME briefly in college and coming home to be stuck with this again, I decided enough was enough, and started searching for alternative input methods. My brief search took me to OpenVanilla, something else that didn't work well, and finally "Fun Input Toy", a beguilingly-named input method which I downloaded from here.
After installing it mostly blind because my Chinese is absolutely not good enough to run programs or read technical documents (or, eh, any documents except for kids' books really) and wincing at the Chinese-only menus, I soon got it working (because the "Next" button in the installer wasn't translated, but you know the position it's in anyway :D). I was initially impressed, but decided to keep my enthusiasm somewhat checked before jumping to conclusions. Not for long though, because it soon became apparent that writing Chinese sentences with FIT is much easier and quicker than ITABC, and it's not as buggy.
By way of comparison, here's the result of typing the string "zheshougemeiyounashougenamehaoting" in both input methods without corrections:
ITABC: 折寿个没有拿手个那么 (4/12 -> not gonna even try translating that mess)
FIT: 这首歌没有那首歌那么好听。(12/12 -> "This song is not as nice as that song.")

Note that in ITABC, once I'd typed the pinyin string, I had to hit space once to start parsing, which yields 折寿, then space again for 个, again for 没有, again for 拿手 and so on. Note that it terminates after 那么 because it only accepts input of up to 10 characters, which means breaking mid-sentence (in practice, after only a few words because the parser gets so confused).
Also note that I typed sentences like this a few times under both systems to allow any learning mechanisms to observe my use of less common words like 歌 (ge1: song).

Also note how ITABC and FIT look once I've typed the entire string in and not hit space yet:

ITABC:


Fun Input Toy:


The FIT input window clearly shows much more information (such as the fact that it parses as much of the sentence as possible, with appropriate options for corrections, compared to ITABC only parsing a couple of characters at a time; usually two).

In summary, ITABC is pretty awful, FIT is very nice. And it's free, so use it!

Thursday, January 15, 2009

Karma headlines

(two successive headlines on Digg)

Sex Offender Wins Lottery For Sex Abuse Victims
Made popular 2 days ago
www.huffingtonpost.com

Sex Offender Who Won Alaska Lottery Beaten With Iron Pipe
Made popular 3 hr 14 min ago
www.mcclatchydc.com

Sunday, December 28, 2008

women and maths and chess...

Two New Scientist articles caught my attention recently:

The first is a bit of mathematical obviousness which points out that: "There are few women at the top of science because there are so few women in science. It's simple statistics."
It uses the German chess federation's statistics to support the theory: there, men outnumber women by 16 to 1 (so if all other (significant) things are equal, there should only be a (1 - 15/16 ** 3 = roughly 18%) chance of a woman being in the top three, if I understand rightly).
Which begs the question, why are there so few women in chess/science/etc? Well, this is the subject of the second article...
Which is about a study where they split the (all female) subjects into two groups. One group was told that women perform poorly at maths due to genetics, and the other group was told that women perform poorly at maths due to social factors. Then they gave both groups the same maths tests and found that the 'genes make women bad at maths' group answered half as many questions correctly as did the 'society makes women bad at maths'.
This supports the idea that women being (statistically) worse at maths is probably wholly due to the negative, self-reinforcing erroneous stereotype that women are genetically predisposed to suck at it. Boo society!

I must admit to allowing myself to openly stereotype people more often than I'd like (i.e. than never), but seeing the power of negative stereotypes to destroy the performance of the maths test subjects it's time to at least keep such preconceptions to myself as much as possible.

Wednesday, December 24, 2008

mini cd/dvd -> Macbook -> oops!

As I inserted the mini CD for the Tevion "Potent Pad" (which I was sure only contained Windows drivers anyway), I thought "uh, how will a slot loading drive pick up a mini CD?". After a few seconds of silence once I had inserted the disc (and poked it in further with an envelope, to bollox things up further), it became apparent that I should have stopped and thought about it, rather than simply thought about it and carried on regardless...

A quick web search yielded predictable advice such as "power off the machine and use a paperclip to extract the disc" or "disassemble the machine and DVD drive to remove the disk". Since I wasn't keen on scratching the optical mechanism to ruin or dismantling the computer, I kept scrolling until I found the following blatantly obvious and blatantly sensible suggestion from 'ashleyman':
"Or just tip it so the drive faces the floor and give it a few taps!!"

This served me well and I safely removed the CD within 5-10 seconds of gently shaking and tapping the laptop with the slot facing down. Sometimes the solution is so obvious that you can completely pass it by!

Wednesday, December 03, 2008

OS X isn't all that great...

It seems like every week or so, OS X prompts me with some system updates that necessitate a reboot (usually Safari and iTunes - why the hell do I need to reboot my computer just because Safari was updated? This is the kind of behaviour people criticised Windows for in the past). I usually leave the dialogue box in the background for a couple of days until I'm ready to reboot, then go ahead.
Every once in a while (month), when I allow it to restart to "finish" updating, nothing happens. I start manually closing programs after getting warnings that each individual program failed to close (although manually closing them causes no problems at all). This time, the Software Updater seemed to hang as well, even though I had already told it to restart my Mac.

In the end, the machine seemed to shut down but the fan was still spinning. After hitting the power button a few times and waiting a minute or two, I held it to force a power-off and reboot. Then, instead of seeing the "Installing updates" dialogue you usually get when rebooting after installing updates, I just got my usual login screen, and sure enough, logging in as normal (after a ridiculous 4 minute delay before the Finder menu would respond to mouse clicks, WTF?) and opening the System Updater started the whole process from scratch.
LAME. Absolutely lame.

Sunday, November 16, 2008

Funny English expression of the day

"Rarer than rocking horse shite."

How to replace a bicycle tube/tyre ten times faster than I do

I hate dealing with punctures. I usually spend about 40 minutes dithering at the task, struggling to get the tube out of the wheel, locating the puncture, patching it carefully, leaving it for 5 minutes, coming back to find that I didn't apply it properly, cleaning it with sandpaper and then jamming the inner tube back in under the outer tyre.

So I was a bit embarrassed to see these videos of a guy removing and inserting the tube (and outer tyre in the process, which seems to just speed things up) in about 80 seconds. I'm still a bit skeptical about dealing with the outer tyre, which seems much tighter and stiffer on my hybrid wheel, but I'll have to try it next time!

Tube comes out


Tube goes in


These videos come from the very useful homepage of Jim Langley. (Note: Opera users such as myself may want to identify as Firefox or IE due to some outdated JS-crippling)

Thursday, November 13, 2008

Meteor MMS on the Palm Treo 680

Meteor uses a system which pushes the WAP/MMS/etc configuration to your mobile phone, but strangely don't provide the details online for anybody with an unsupported phone. In fact, when I phoned their customer service I had to push the agent to speak to his supervisor and get the settings, since he had no idea what I was talking about (indicated by his question "Did you say I.T. address or I.P. address?").

It's not possible to specify those settings completely in the Messaging program on the Treo 680; instead, you need to modify (or copy and use) the settings in (main) Prefs->Network. This configuration worked for us:
Service: Meteor MMS Copy
Connection: GPRS
User Name: my
Password: mms
APN: mms.mymeteor.ie

Then in the Messaging program, go to the Preferences menu, select the Network tab, change "Network Configuration" to manual and enter the "Edit..." dialogue, where you can enter the following settings:
Message centre number: +353857000000
Email centre number: [blank]

MMS HTTP Proxy: 10.85.85.85:8799
MMS URL: http://mms.mymeteor.ie
Network Profile: Meteor MMS Copy

This works for downloading MMS messages.

Tuesday, November 11, 2008

the arithmetic calculator exercise in GFA Basic

For a couple of reasons, I tried that arithmetic calculator exercise in GFA Basic (v3.6 for the Atari ST; why not?), and although I selected a somewhat different approach, I think it's really like a non-recursive version of the recursive Lisp version I posted before; with state in variables which persist for the whole loop. This is where side-effects can get mysterious, compared to the neater encapsulation of state in each recursive call's parameters.

randomly entertaining Chinese sentence

I check pretty much every new word I come across in my study materials on dict.cn, which also lists example sentences containing the term.

Here's a nice one I found when looking up the character 肥 (fei2), which according to my book means "(of clothes, shoes) loose*, (of animals) fat":
我被两个肥胖的女人紧紧地挤在中间,以致于要站起来下公共汽车都很难。
I was so tightly wedged between two fat women that it was difficult for me to get up and leave the bus.

:D :D

* although I couldn't substantiate the first meaning from the online dictionary..?

Saturday, November 08, 2008

Common Lisp: arithmetic calculator exercise

Following a post on the Atari ST forum I tried a little exercise to write an arithmetic expression parser for expressions like "24 - 3*9 + 9/3". I was surprised to find it a little difficult, taking about an hour even with the concessions I made (accepting input as a list rather than a string, and not checking for well-formedness of expressions). My code is on paste.lisp.org and I'd love to see any improvements or tips. Embarrassingly, I took two semesters of the final year compiler construction course in DCU and did quite well at it; parsing of programs was a central topic on the course! I guess it's easy to take for granted your skills at 'abstract' coding and notice they need a bit of exercising.

Saturday, October 25, 2008

ntl's expanded internet pipe

Soon after moving here last year, we decided to get our TV, broadband and phone service through ntl rather than get TV from them and broadband/phone through Eircom or some reseller, since Ireland has apparently the most expensive line rental in the world (?? thanks, Tony O'Reilly for exploiting the competition-free market and Comreg/competition authority for allowing it).

They recently retooled their broadband packages, so that the old 6mbit price now gets you 10mbit and for €10 more per month you can get 20mbit (I wouldn't bother with that unless I was sharing with a few people, though).
I had to call up to get it though, since they weren't nice enough to automatically shift me over to the new package - this is really something ISPs should do when they improve their packages.

It's working pretty good too - close to the quoted 10mb:

Thursday, October 23, 2008

Lexmark X4550 wireless woes with OS X

I picked up a fairly cheap Lexmark X4550 wireless printer/scanner/copier about 6 months ago and soon noticed that it stopped working every time I restarted the router.
After a long conversation with a fairly patient technical support guy at Lexmark proved mostly fruitless, I dug a little further and ran a packet sniffer (Wireshark) over an attempted print job.

This prompted me to double-check the printer settings, which showed a device URI of lexnet3://192.168.1.3:1. Which is certainly wrong, as the printer is at 192.168.1.4. I'm not sure why it doesn't just use DNS properly, but anyway.

Trying to correct this, I stumbled across this post explaining how to modify the device URI via the CUPS web interface available on OS X. And it works! Good old Unix!

article: "Early Childhood Education: The Key to Success in Life"

Anyone who has or expects to have children should read this article about preschool learning as soon as possible.

After emphasising some of the importance and benefits of preschool education, it lists some basic and simple ways in which you can help educate your bairns. As usual with such material, there are 'obvious' things that never occurred to me - like placing a young baby face-down from even one month of age, because he will naturally want to raise his head which will help build up his back muscles which will improve general strength and co-ordination. The paper-crumpling trick is clever too.

Well worth a read!

Friday, October 10, 2008

classy typing tutor

This is the funniest-looking educational game I've ever seen. Check out the screenshot :D The description for the game calls it "an educational children’s casual game". It certainly would have appealed to my childhood self.

. o O ( "Cop smearer"?? )

Sunday, August 24, 2008

Ireland's gradual transformation to a police state

Well, here we are. The Department of Justice, Equality and Law Reform have made it so that all migrants to Ireland from outside the EU must be fingerprinted (and their details shared with who knows how many foreign agencies). And of course, the costs for this are passed on to the migrants themselves - they will pay another €50 on top of the old €100 "registration" fee to lose their privacy. I have to wonder what practical use there will really be for the fingerprinting.

The "Land of the 100000 welcomes" is long dead and buried by this point. What disturbs me is all the people who feel that all foreigners should be fingerprinted and they're lucky they're not just sent home immediately anyway. What if all Irish citizens had to be fingerprinted? Would that be okay? No? So why the double-standard, and where does it stop?

Saturday, August 23, 2008

Refactoring threats

Entertaining quote of the week (a comment on an article about a newbie employee running a "NEVER RUN THIS" database recreation script after being told not to) from a user on thedailywtf.com:
Re: Do not run this script, ever!
2008-01-25 15:45 • by morry (unregistered) 173406

I've always thought it's better to put these things into the positive, i.e. don't use "don't". For example:

RUN THIS SCRIPT WHEN YOU WANT TO BE FIRED

EXECUTE THIS PROGRAM WHEN LIFE NO LONGER HAS MEANING FOR YOU

IF YOU LIKE EVERYONE HATING YOU, THEN START THIS JOB

MAKING TOO MUCH MONEY? DO THIS TO REDUCE YOUR PAYCHECK TO 0!

GET ESCORTED OUT BY MERELY PUSHING THIS SHINY RED BUTTON

Thursday, August 14, 2008

Stupid thing of the day

Eclipse (the popular Java IDE) has an update manager which allows it to automatically fetch and install or upgrade new versions of various components and plugins.
However, it can't upgrade itself from version 3.3.2 to 3.3.4.

WTF.

Wednesday, July 30, 2008

"Who gives a shit?" attitude -> better mental performance

This article was a big surprise to me. The gist is that using the executive function of your brain (switching from deliberation to implementation - making and acting on decisions) has a strong negative impact on all sorts of mental activities.
For example, deciding whether to have cake or cornflakes for breakfast could be enough to make you perform poorly at an interview later on.

A further implication of this (to me) is that people who coast through much of the day like zombies (especially in the morning), not making many decisions, are much better able to perform when they need to, because they haven't depleted those resources yet.

The moral of the story: if you want to improve your overall mental performance, get into the habit of saying "who gives a shit?" about irrelevant decisions like where to put the furniture or whether the curtains need to be washed again this week. Don't deliberate over mundane issues. Don't waste your energy. Just pick the first reasonable option. I'd like to know if strategies like this can minimise this effect, or if we really have to go around like cattle - I know I do, most of the time... Is that what girlfriends are for? To decide where the couch and TV should be and what washing powder to use, so that I can reserve my brain power selfishly for 'clever' use later (which rarely happens)? Seems a little unfair, really...

I have more questions. How do we recover from the effects? How long does it take? Can we speed it up? What about meditation, or induced alpha/theta/delta brainwaves (i.e. by listening to binaural beats, say)? Why does it happen?

Enough rambling (I guess...), I'm off to dodge some decisions! Probably.

Wednesday, July 23, 2008

(Auto-)Growing Panes

In another Swing-related weirdness note, it seems that a certain combination of apparently logical options regarding GridBagConstraints and a JTextArea will cause the JTextArea and enclosing JPanel to expand horizontally by gridBagContraints.ipadx pixels per step, forever.

After scratching my chin in confusion, I whittled out the following minimalish example that demonstrates the result:

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.border.LineBorder;

public class TextAreaExample {
public JPanel createContentPane() {

JPanel contentPane = new JPanel();

JPanel mainPanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
// ipadx > 0 causes textarea panel to grow horizontally forever if linewrap is set!
c.ipadx = 1;

JPanel leftPanel = new JPanel();
leftPanel.add(new JLabel("Left"));
mainPanel.add(leftPanel, c);

JPanel logPanel = new JPanel();
logPanel.setLayout(new BoxLayout(logPanel, BoxLayout.PAGE_AXIS));

JLabel label = new JLabel("Hello");
logPanel.add(label);

// create misbehaving textarea
JTextArea log = new JTextArea(10, 40);
log.setLineWrap(true);
log.setBorder(new LineBorder(Color.BLUE));
logPanel.add(log);

mainPanel.add(logPanel, c);

JPanel rightPanel = new JPanel();
rightPanel.add(new JLabel("Right"));
mainPanel.add(rightPanel, c);

contentPane.add(mainPanel);
return contentPane;
}

private static void createAndShowGUI() {
JFrame frame = new JFrame("JTextArea growth test");

TextAreaExample demo = new TextAreaExample();
frame.setContentPane(demo.createContentPane());

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}


I can get around it by setting a preferred size on the JTextArea (a size of 0,0 seems to do the trick without changing the initial layout), but what the hell?

Monday, July 21, 2008

Swing and a miss

Does this method Javadoc from the Swing API confuse you? It confuses me:
/**
* Sets the the vertical alignment.
*
* @param alignmentX the new vertical alignment
* @see #getAlignmentX
* @beaninfo
* description: The preferred horizontal alignment of the component.
*/
public void setAlignmentX(float alignmentX) {


As you can see, the method description and param seem to conflict directly with the beaninfo description. I was sure the first two are a typo, copied from the alignmentY equivalent, but let's have a look at setAlignmentY:
/**
* Sets the the horizontal alignment.
*
* @param alignmentY the new horizontal alignment
* @see #getAlignmentY
* @beaninfo
* description: The preferred vertical alignment of the component.
*/
public void setAlignmentY(float alignmentY) {


???

Also, using it is confusing and the docs don't seem very helpful. I created a JPanel using a vertical BoxLayout, so that as you .add(component)s they stack up beneath each other.
To the empty box panel I added a JLabel with the text "Log" and beneath that, a JTextArea which would hold the log output.

However, I noticed on running the program that the label was not left-aligned - instead, it was indented by about 40 pixels beyond the log textarea beneath. Worse still, when text appeared inside the JTextArea, the label above would jump horizontally right, bizarrely. So the most logical thing to do seemed to be to call label.setAlignmentX(Component.LEFT_ALIGNMENT) to keep the label aligned to the left side of its containing box.
Seemed to be the logical thing to do. But no, this caused no obvious change. Various combinations of this did nothing, until I made the same call on the textarea underneath.

So if you have a vertical box containing a label with a textarea underneath it and you want the LABEL to be left-aligned, you have to tell the TEXTAREA to left-align itself.

...WHAT?

Wednesday, July 09, 2008

The great antivirus scandal of 2008

This report is pretty scary. It's understandable that everybody overlooks the fact that virus scanners can be vulnerable, especially when they're built with lots of 3rd-party plugins (e.g. upx/zip/arj/rar/etc unpackers).

But the fact is, you can become automatically infected by a virus without running the infected program/trojan yourself; the virus scanner scans it automatically, but the file is designed to exploit a vulnerability in your virus scanner and you become infected.
That's a lot more dangerous than having no AV software and just being careful which programs you run...

Symantec is among the worst here, with about 32 vulnerabilities listed compared to 6 or 7 in FProt, AVG and BitDefender.
Personally, I think it serves AV vendors right for coding their products in languages as dangerous as C and C++, which are so vulnerable to buffer overflow mistakes. And nobody can code without mistakes. And the frequency of mistakes increases with code size, of course. They should have written their scanners/plugins in a better programming language (e.g. Lisp).

Tuesday, July 01, 2008

Update on Gambit-C Scheme benchmarks

Thanks to some helpful comments from a few people on my previous post about Gambit-C Scheme, I rebuilt and ran (with a larger minimum heap size specified) those few benchmarks I was bothered pulling off their site and the shootout site for SBCL (which is a very fast Common Lisp implementation I'm interested in using as a kind of reference).

The results in general are much better:

time ./fannkuch -:m20000 11 > output_fannkuch

real 0m9.931s
user 0m9.465s
sys 0m0.172s

time ./fasta -:m20000 25000000 > output_fasta

real 0m29.843s
user 0m25.220s
sys 0m2.700s

time ./binary-trees -:m20000 16 > output-binary-trees

real 0m2.770s
user 0m2.581s
sys 0m0.089s

time ./pidigits -:m20000 2500 > output
real 0m3.322s
user 0m3.093s
sys 0m0.110s


A range of improvement is apparent, with binary-trees benefitting a lot and pidigits not really getting much better.
I picked a 20 meg heap because a) it seems wasteful for individual programs to reserve (and probably waste) huge chunks of memory, if you're running a lot of programs b) when I tried higher values up to 50 megs on the fasta benchmark, it was faster, but only by another .2 seconds or so; about 1-2%... and c) Most other languages, and in this case SBCL, don't seem to request more than about 20 megs for their initial heap size either.

Of note is the fact that the prebuilt version produced slightly faster code than the version I compiled myself, specifying the optimisations mentioned in the INSTALL.txt document. Not sure why... These numbers are for the Gambit I compiled myself, and I didn't feel like dumping it and re-installing the prebuilt version just yet.

Anyway, these are nice results!

Sunday, June 29, 2008

How fast is Scheme? Well....

Thinking that it'd be a good idea to become familiar with Scheme as well as Common Lisp (but, er... probably after I've read Practical Common Lisp and amn't mentally overloaded, what with me being mental so busy and needing to focus my efforts in a more single-threaded manner), I checked out Gambit Scheme in the hopes that it'd produce faster code than the other free Scheme implementations.
I don't know much about Scheme (or Lisp at all really; I've only become interested in it during the last month or so) but it seems that the Scheme compilers produce quite sluggish code, at least looking through the grainy, distorted lens that is the Computer Language Benchmarks Game.

From some of the microbenchmarks published by the Gambit guy(s) on their homepage, it looks as if it fares really well against the Chicken and Mzscheme compilers, but I wanted to examine its performance on problems relative to SBCL, which is the Common Lisp compiler I've arbitrarily chosen.
Since it's not featured on the language shootout, I pulled the SBCL code for a few tests there as well as the Gambit code which was already prepared on their site (why hasn't Gambit appeared on the shootout site for the nosy hackers who want to find out if less mainstream (man I hate that word) languages are ridiculously slow? Many of them aren't! And they're more expressive and comfortable than C++/Java, use them!) and ran a few comparisons.
SBCL comes out very much on top; in general the Gambit programs take two or three times as long to do their job (although I haven't looked at memory usage). But as far as Scheme compilers go, Gambit seems to be improving things.

(Really dodgy) timings on my Macbook (input values = whatever's on the shootout site):

Gambit:
pidigits
real 0m3.611s
user 0m3.508s
sys 0m0.066s

binary-trees
real 0m7.519s
user 0m7.309s
sys 0m0.130s

fannkuch
real 0m12.571s
user 0m12.089s
sys 0m0.205s

fasta
real 0m46.334s
user 0m42.284s
sys 0m2.668s

Lisp SBCL:
pidigits
real 0m2.422s
user 0m2.018s
sys 0m0.308s

binary-trees
real 0m1.899s
user 0m1.723s
sys 0m0.127s

fannkuch
real 0m6.221s
user 0m5.982s
sys 0m0.098s

fasta
real 0m20.730s
user 0m15.267s
sys 0m4.375s

(ratio-pidigits: 1.5
ratio-binary-trees: 3.959
ratio-fannkuch: 2.021
ratio-fasta: 2.235)


One thing I've noticed from these coarse measurements is the "sys" component of the execution time is mostly higher for SBCL; maybe this means a lot of allocation and de-allocation of stuff is going on ...Or something.

Extra legs on a dog

This hi-larious entry on the wikiwikiweb offers a series of biological analogies for the origins of some popular/not-so-popular programming languages, on the premise "how other languages became ObjectOriented octopi".

I particularly like:

JavaLanguage
  • ..made by taking an 8-legged dog, housebreaking it, and tearing out its skeleton. Then giving it a machine shop.

    • a boneless 8-legged dog manages to be less useful than either an octopus or a dog - but it comes with a machine shop, so that's good.

That said, this is exactly the kind of thing that I would chuckle ceaselessly at, for which even fellow coders would shun me for being lame and non computer scientists would simply presume me to be insane. Fair play, really.

Tuesday, June 24, 2008

Lisp problem 10: RLE of a list

This one worked out much easier, but again, I went at it non-recursively. Bitching about my struggles with the previous problems made me realise that I had solved most of the previous problems recursively but non-tail-recursively.
I guess there's a danger there of writing really poorly-performing functions on the assumption that the compiler will optimise them. Actually, I don't even know if SBCL does tail-call optimisation... It somehow seems easier to express tail-recursive solutions in Haskell, so far anyway - as a complete newbie to both languages.

;; P10: Run-length encoding of a list.
(defun encode (list)
(let ((chunked (pack list)) result)
(dolist (chunk chunked)
(setf result (append result
(list (list (length chunk) (car chunk))))))
result))


Oh yeah, how do you get around doing that ugly (append result (list (list x y))) stuff? I assume that's super slow, unless Lisp lists have a pointer to the last element for quick access since (you'd think?) appending is common. But then, some of the stuff I read in Practical Common Lisp suggests a push/reverse pattern, which to me seems a bit awkward.

99 lisp problems. Some are hard!

This much publicised set of 99 Lisp problems (taken from an original set of Prolog problems) seems like a nice step for me to take in learning Lisp as a novice to the language.

I figured the first few would be really easy with a smooth learning curve as the questions get more difficult. Certainly, I didn't expect to spend at least two hours screwing up question 9; an ostensibly straightforward problem requiring you to convert a sequence into a list of sublists, grouped by consecutively equal elements (i.e. (1 4 4 8 1 9 1 1 1 2 2 3) -> ((1) (4 4) (8) (1) (9) (1 1 1) (2 2) (3))).

After trying to solve this one a few different ways, I rejected a recursive approach and simply looped through all the elements, doing dirty stuff:
(defun pack (list)
(let (a main-list)
(dolist (x list)
(if (and (not (null a)) (eq x (car (last a))))
(setf a (append a (list x)))
(if (null a)
(setf a (list x))
(progn (setf main-list (append main-list (list a)))
(setf a (list x))))))
(setf main-list (append main-list (list a)))
main-list))


I had a quick peek at the solution provided on the site and didn't bother going through it except to note that it was indeed recursive (and not tail-recursive). Partly because some of the identifier names are in Portuguese and partly because it looks similar to the mess I had when I tried to do it recursively; I'm just not comfortable with how lists work yet - I was getting stuff like ((1 (1 (2 3)))) and ((1 (1 (2))) . 3) and all sorts of other crap.
I'm sure I could have done this quicker (and much longer and uglier) in Java, but not figuring it out properly in Lisp is making me feel a bit stupid. Wah.

Friday, May 23, 2008

From I Ran to Eye Rack

In a thread on codeproject, someone humorously commented that "pedophile" must mean somebody with a foot-fetish: American pronunciation has even changed it from "peed-o-file" to "peddo-file", which is almost equivalent to "encyclo-peddy-ah" (since American spelling similarly converts that 'ae' glyph to an 'e').

Another funny dodgy American pronunciation is the popular "eye-raq / eye-ran" thing. It was entertaining to hear that our ex-Taoiseach Bertie Ahern was introduced as "Bertie Ay-hern" by Nanci Pelosi on a recent trip to the US.
As culturally-prevalent-and-nobody-corrects-themselves pronunciation errors go, it seems as bad as the Japanese 'l'->'r' transliteration (take the eravator to the rower reveru, prease), since at least Japanese have the excuse that the 'l' sound doesn't appear in their language and they thus have trouble pronouncing it.

Tuesday, May 06, 2008

gymnastic bounces, late

Received 3/5/2008 (happy birthday):

Your membership in the mailing list Announce-gymnast has been disabled due to excessive bounces The last bounce received from you was dated 29-Dec-2003. You will not get any more messages from this list until you re-enable your membership. You will receive 2 more reminders like this before your membership in the list is deleted.

Excessive bounces, but the last one my account apparently sent was four and a half years ago? I don't think I even subscribed myself to that list, though I was in the gymnastics club in first year of college. Weird.

Friday, April 11, 2008

Java's arithmetic operators

Here's a weird little one that confused me at first:

 @Test
public void testWeirdArithmeticOperators() {
double a = 1.0 / + + + 2.0;
assertTrue(0.5 == a);
String s = + + + + 0 + "abc" + "def";
assertEquals("0abcdef", s);
}


After playing about for a bit, switching some +es to -es and vice versa, I realised that the effect is that each + or - symbol could be rewritten as follows:
+ -> (+1)*
- -> (-1)*

So that the expression "+ + + 2.0" becomes "(+1) * (+1) * (+1) * 2.0" = 2.0, and the expression "- + + 2.0" becomes "-1 * +1 * +1 * 2.0" = -2.0. Thus, the sign of the result is negative for an odd number of - symbols and positive for an even number.

Seems a little pointless, but I suppose the logical way to see it is:
- + - x = - (+ - x) = - (+ (-x)). It makes sense then that the parser would accept it, but in it that form it looks wrong to (my) human eye.

Also, in writing this post I noticed that JUnit's assertEquals doesn't really like doubles:
assertEquals(0.5, 0) passes, as does assertEquals(Double.valueOf(0.5), Double.valueOf(0.0)) and other combinations. That's why I needed to use assertTrue(...) and == above. Huh.

Tuesday, April 01, 2008

the poor man's breakpoint

Since Eclipse is kind of very ridiculously slow betimes, I tend to avoid making it do too much work, for fear of it getting stuck in a rut and slowing down. Partly because my work machine is pretty much a doorstop, for the purposes of working with Eclipse (512mb RAM just doesn't cut it, if you want a browser and other apps open at the same time - I had to stop using the latest Opera snapshots while coding, as they use too much RAM at the moment, compared to Firefox 3.0b4).

So instead of running tests/etc in the debug perspective and adding breakpoints where I want to stop (if that block of code is executed), I've taken to doing things like this instead:
throw new RuntimeException("FUCK");
This means I get a stack trace showing how we got to the current state, which is often enough to realise what the problem is (at least, it was just now; I saw that a method I didn't expect to be called was being called by a parser for poorly-formed XML messages. Until that point, I didn't realise the messages were now poorly-formed as they weren't before I swapped XMLSerializer for LSSerializer earlier today).
Also, it's easy to search and remove your debugging throws afterward, since they contain the reasonably memorable, short string "FUCK". Of course, you wouldn't want to forget about it and leave one in a currently unused (as far as you know) method, lest an end-user find that their application is throwing an exception because FUCK. :)

Perhaps a more subtle keyword could be selected (how about "Fire in the hole" or "Get to the choppa!")...

Friday, March 28, 2008

how... odd

Here's a funny random thing. Residents in some countries can apply for an Irish visa online.

They're even nice enough to provide translations of the "Information on completing Online Application" into other languages, including Chinese. However, in their list of countries for which they allow online visa applications, China is not present.

So why the hell did they bother translating the "how to use the online application system" PDF into Chinese...?

Welcome to the Irish government. Home of weird bureaucracy and silly contradictions.

Also, the actual web application tells Opera users to upgrade their browser because of some buggy cookie test. As usual, an Irish government site/webapp ends up poorly designed and coded, and probably cost at least €10M. Saps.

Monday, March 24, 2008

Freeze! squad

Here's one of the things I really like about Mandarin Chinese - its simple straightforwardness; a lack of needless obfuscation. The Chinese phrase "别动!" (bie2 dong4) usually means "Don't move!". The character "队" (dui4) means a squad or team.

Combined, the resulting term "别动队" means "special ops team". Literally, "don't move squad".

:)

Thursday, March 20, 2008

When is a clone not a clone? When it's half a clone!

After finding that the clone of a two-dimensional array in Java seems to not be a clone, I searched the web, already strongly suspecting the outcome.

Behold (from one of Sun's references):
A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared.
Then that's hardly a clone now is it? Damn you AvatarJava. Daaammmnnnnn youuuu!

Wednesday, March 19, 2008

我找到了书!

I ordered a Wacom Bamboo One graphics tablet from dabs.ie about two weeks ago, and am pretty impressed by it (once I installed the updated drivers for my Macbook, since it was sucking with multiple users/sleep/USB disconnect+reconnects). It's nice for scribbling and drawing, even if it just makes me realise what a poor graphic artist I am. The main reason I bought it was for studying Chinese - up to now, I'd been using a scheduled revision program (first Pauker, then Mnemosyne, then when it wouldn't build on OS X Leopard due to one of its Python dependencies being a bit outdated, Anki) to learn Chinese characters and sentences, and writing the characters vertically on paper as I revised them. However, to avoid spoiling the recall process, I was having to draw gridlines and cover up already-drawn characters so I wouldn't see them when presented with flashcards for review. There two problems there; one was that lots of paper was being used up needlessly, and two was that it was fiddly and a hassle, so I stopped doing it due to my self-discipline not overcoming the coefficient of resistance (my laziness is a rough cloth).

Since the graphics tablet arrived, I started using it to sketch the characters in Seashore, a simple bitmap drawing program.


Then I check if I was correct (if not, I draw each character four times or so), clear the canvas (by hitting backspace) and grade myself in Anki, moving onto the next item. It's faster and easier, two reasons which have helped me keep doing it. Along with some truly inspiring ideas (the "how many things will I definitely do tomorrow" game and the "I'll just get the file out" trick) I read on Mark Forster's site, which you should incidentally go and read now, by the way, since it might just help you change your life for the better.

Tuesday, March 11, 2008

Newsflash: Eclipse is bloody slow

It's probably not news to anyone who has ever used Eclipse, and I've been aware of the fact since I started working with Eclipse as my IDE in 2006. However, right now, on this admittedly rubbish machine (PIII 1ghz, half a gig RAM, running Opera as well with a million tabs open which takes up 80-100 megs), it took about 90 seconds to get from clicking the "Find and install..." menu option in "Help->Software updates" to displaying the "Install/Update" dialogue box. It doesn't seem necessary to do a lot of work to get there, since that dialogue simply contains a radio button choice between updating currently installed features and looking for new ones.
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

Well, after being forced to go down the manual speed profiling route, I'm pretty happy about the results. Manually inserting timing code around loops of single (if possible) calls is nice because you can focus your search in a reasonably directed, intelligent way. Since giving up on Eclipse's TPTP profiler yesterday evening, I was able to optimise various parts of the code so that the main client/server conversation executes five or six times faster than previously. Most of the optimisations were of the "cache objects instead of constantly recreating them locally" variety, which can introduce errors (which is always a risk when adding more state to your code, but hey, welcome to one of the downsides of OO) but can also improve performance drastically.

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

I had Eclipse's update manager automatically "upgrade" some of the component versions, including the TTPT tools I was using to try to profile some VERY SLOW code I'm working on, and since then (and following multiple restarts of Eclipse and a reboot), I cannot profile any Java code.
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...

Having more experience in Java than most of the other languages I've coded in, I was interested to read this article from 2004 on using some functional programming concepts in vanilla Java.
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

Cycling back from snooker on Tuesday, I stopped in a Chinese takeaway in Beaumont, about 3km from home. Laden with chow mein and... whatever I got for my girlfriend, I decided to cycle on the path to the petrol station just around the bend (where I could buy a 2L bottle of something to drink, since coke cans are €1 a pop in the takeaway), rather than bother to cross back onto the road, cycle for 20 seconds and cross again to get to the petrol station.

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?

After a bad crash on my MacBook, I rebooted via the power button and logged in again to find my fonts banjaxed (i.e. most of them missing, notably Chinese character fonts). A cursory investigation led me to check the Font Book application, which should contain two libraries called User and Computer, which contain the default set of 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

Recently, I had a bad crash on my MacBook while it was downloading some torrents. When I came back, I had to use the power button to restart the machine, and after the reboot, some things were broken. First, Font Book contained no fonts. Second, LyX didn't run. Third, Atlantis (a MUD client) didn't run either.

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?

My Macbook crashed hard for the first time last night, and a few things got bolloxed up. For one, my fonts were and are still knackered - opening the Font Book application shows 0 fonts, even if I tell it to add fonts. Adding fonts it tells me not to add causes it to use more and more memory until the allocator won't give it anymore and it dies (around 1.6 gigs at this stage).

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:

  1. 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.
  2. 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?

GParted decided to balls up before finishing a move and resize job where I wanted to decrease my oversized swap partition from about 4 gigs down to 1.2 gigs and increase the size of the partition I used for storing big media files (immediately next on the disk).

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

After a few days of limbo, having started my postgraduate course in DCU, I still wasn't able to get into the secure(ish) research bay. Nagging to the school office did no good, so I went to the Estates office in person against the recommendation of the school secretary. Handily, the lass in the Estates office swiped my card, noted that I hadn't had privileges to open those doors added and dragged the equivalent permissions onto my set - all of 2 minutes' work.
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.

LOS ANGELES (Reuters) - Vanessa Hudgens, the star of the wholesome, made-for-kids TV movie hit "High School Musical," apologized on Friday for a nude photo of her on the Web and Walt Disney Co. said it was sticking by the performer.
...
"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

Amazing what finishing college and quickly walking into a full-time job does for your free time. In the sense that it almost totally erases it. But I'm alive, anyway. And the job is okay, writing a testing utility for ATM controller software. Whee.

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!

I was pretty impressed by this new product called Pluribus - presumably from the Latin motto that appears on American currency meaning "From one comes many" (probably also on a counterfeiter's t-shirt). So, it uses a webcam or something to dynamically adjust its configuration to split a single video stream over any number of projectors to make a bigger, better quality image. And apparently you can just plug projectors in and plonk them down anywhere and it'll do the stuff automatically.
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"

It's over. It's over. It's over. Takes a little while to really sink in, but now that I've finished my degree in Computer Applications (and what a truly fun degree it was!) at DCU, I'm free to do all those things I planned to get into during college but never had the time.
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.