head on collision with a bicycle

September 11th, 2007

I had a rather unfortunate happening today. I was leaving the supermarket, which is on this narrow, but busy street (too narrow for its needs, as the case often is here). I had reclaimed my bicycle from the over crowded bike stand and I was about to get on it. I had a loaf of bread in my left hand which wouldn't fit in my backpack, so my movements were a bit impaired.

Now this street is only wide enough to allow one motor vehicle to drive, so if there is a car coming in the opposite direction, you have to basically look for a space to squeeze in so you can pass each other. And there's normally quite a few cars on the street. On both sides you have these concrete poles every 2m to draw out a narrow sidewalk for pedestrians (but which is level with the street).

As I was making my way out, there was a van parked right up against the bike stand, which blocked my view in the direction I was going. On this street that's quite common. So just as I mount my bike and push off, I see around the van and there are two bikers coming at me at 3m away. Oops. I was too far out to pull back in behind the van, and it was too late to speed off as well, so basically I was stuck. Terrible timing. A woman rode the first bike, probably 40ish, the other biker was a bit behind. She hit the brakes and stopped just so her front tyre lightly bumped into my front wheel. An inexcusable traffic blunder on my part.

She came to a full stop, I was relieved. The other bike just behind her also stopped. I look up at her. She gives me a stern, but somewhat understanding glance. Says nothing. I say "sorry" and take off. This is the way people are here. Calm. Patient. They've figured out that getting mad doesn't do you any good. I forced her to come to a complete stop. Very annoying. But ultimately harmless, and nothing to get all riled up over.

But these are the kinds of blind spots we have. On my bike I maneuver just fine. Two minutes after the incident I caused a kid a bit of mild panic when he thought I was making a turn just in front of him and he was going straight. Of course I could see I would make my turn well before he could crash into me, so there was no risk. But these are the things we don't think about. On the bike, fine. But while getting on the bike with a heavy backpack and one hand not fully available, reaction time increases.

recover lost stuff from memory

September 10th, 2007

This has happened to you before. I'm painstakingly typing a long email on gmail and I'm not sure that I should send it yet, cause it feels like I'm forgetting to mention something. So I want to save it as a draft so I can finish it later. Somehow I hit Discard instead. :doh: Gmail flashes the notice your message has been discarded, but I don't usually read those messages, so I navigate away from the page, and *just* as I click the link the meaning of the message dawns on me. Shit. Now it's too late to undo the action. Son of a. :fero: :wallbang:

Okay, relax, perhaps all is not lost. A couple of weeks ago I went over how you can find stuff on disk by searching the raw data. The same *can* be done with memory. See, just because my message is gone and gmail doesn't display it anymore doesn't mean it's not still possibly somewhere in memory. It just isn't being displayed anywhere.

There are two ways to access physical memory. The two interfaces are /dev/mem and /proc/kcore. As root, you can read from these. (However, if you try writing to them you'll probably mess up your system.) They are not identical, and it seems that /dev/mem doesn't let me access memory above 896MB (High Memory Support in linux kernel parlance), so just use /proc/kcore.

To find that lost message in raw memory, it helps if you can remember a phrase from it. Then do

cat /proc/kcore | grep -a --color -C1 "a phrase from it"

This will search the memory treating it like text, and highlight the phrase when it's found. It also prints "one line" above and below the line where the text was found (although considering this is binary data, the notion of "a line" is somewhat diffuse). Anyway, you probably now have enough context to get your whole message. If not, increase it to -C2 and so on.

This way I was able to recover my message. :party:

In principle, you can also recover lost files this way, provided they are still in memory, but searching for binary data within binary data is a bit trickier, so it would take a clever approach.

bad ui on display in dia

September 7th, 2007

Dia is a really useful application. Perhaps there is some better one out there, but it's the best app I've seen for drawing diagrams. When I need to draw a diagram for a technical paper or a presentation, dia is essential.

Having said that, it has some really bad interface problems. Not that ui is any kind of expertise of mine, to me it's just common sense and if something gets in my way I think it's badly designed. For that matter, I have read quite a few criticisms of bad ui, but never one that strived to be complete, to give a full review of the application. It seems that ui critique is really about pointing out one or two bad bits. And that's what I'm doing here as well. So obviously this doesn't mean the whole application is useless and everything is wrong.

MDI/SDI

Some people have really strong feelings about this issue. Personally I think it has to be settled on what is best for the application in question. Firefox is Single Document Interface, ie. you have multiple windows. Opera is Multiple Document Interface, where you have one main window and more windows inside of it ("multiple" refers to these sub-windows). To me there is no question that Firefox is much better off for this. Everything you need to do in Firefox is constrained to the one window, you don't need multiple windows visible unless you're doing some kind of copy/paste activity.

But editor apps have other needs. Photoshop is SDI (as are most image editors), the gimp is famously (and painfully) MDI. Dia copies this bad choice. I suppose the argument is that when you have your canvas window separate, you can maximize it and work on your document full screen. However, unlike Firefox, you need a lot of tools to do this, so unless you've memorized keyboard shortcuts to select them, you have to bring the palette, layers and other windows to the front anyway. This is a huge pain when you don't *dedicate* your workspace to editing, but you also have half a dozen other applications open.

No menubar in the canvas window

This is my biggest gripe with dia. For better or for worse, this is the kind of diagrams I draw in dia (below). I rarely use the in built stencils, because they all assume some specific kind of diagram other than what I need.

dia_filemenu.png

As it happens, one of the more useful functions in dia are the layers, when dealing with more complicated diagrams. To bring up the layer window, I have to right click on the canvas to get the main menu first. Why this menu isn't fixed at the top perplexes me (apparently it's possible to change this, but defaults are much more important than configuration options). Well, you might think what's the difference, either way it's just one click away. The difference is that when it's a fixed menu, it's always in the same place, it makes it easier to use, you locate items quicker visually.

A lot of useful things are in the main menu. Like alignment of objects. This is found in the Objects > Align submenu. Needless to say this is quite a pain to invoke more than a couple of times. This should probably be made into a palette window.

One thing I really like about dia is the number of different formats it can output. Most of my diagrams are pngs. This is called Export in dia. But to export my diagram (rather than save it in dia's own format), I need to choose File > Export from the menu. There is no keyboard shortcut for this action. If I'm tweaking my diagram to see if it looks good in a report, I have to do this export ritual several times. Awful.

Other quirks

And do you see that zoom control in the lower left corner? I can't change the zoom level with my mousewheel (like in the gimp). Bad.

In the above screenshot, if I wanted to place some object above the rectangle, a distance greater than what I see in the canvas, I have to scroll up. Except that the scrollbar doesn't seem to allow this, it seems to indicate that the canvas can't be larger than this. The mousewheel will actually scroll up, which is inconsistent with the scrollbar.

The Power of Nightmares: explaining terrorism

September 6th, 2007

I came across this really interesting program from 2004 produced by the BBC. The Power of Nightmares explains terrorism and indeed the current geopolitical climate in terms of the US neoconservatives' need to scare us in order to battle liberal values. Interestingly, the current radical Islamist movements are explained to stem from what was a similar movement to protect Arab states from corrupting Western influence.

The program is in three parts (180min), see them all on:

On the other hand, if you're going to be flying anytime soon, you might do better to skip this one, as it will infuriate you even further at all the bullshit you have to go through and have your toothpaste and scissors stolen.

working in a job agency - worst job ever?

September 5th, 2007

Suppose you want to buy an mp3 player. Your local electronics store only has 3 different mp3 players. So the choice is pretty clear, it's easy to compare the 3 models and find the one that suits you much better than the other 2. But then you learn that abroad they have hundreds of them. So although you're limited to just the 3, *theoretically* there is much more choice. Would that not detract from your satisfaction of choosing the best one of the 3 you can get?

There is compelling talk from TED by Barry Schwartz about how having a lot of choice ruins your experience, because you have to take your pick out of an enormous set of possible choices, which leaves you agonizing over whether you made the right choice or not. There are so many choices, which means that whichever you pick, there is a chance that some other option would have been a little better still. Whereas if you only had a few options to choose from, you would choose the one best for you and know that none of the others could possibly make you any happier, because they weren't as close to your preferences as the option you chose.

So that makes me think about people who work in job agencies. I mean these guys must see tens of jobs everyday, thousands of jobs every year. And it's not so much that they are in a position to choose between all of these, but just *knowing* about them must make you think. Many other jobs may not be as enjoyable, but where else are you constantly confronted with a ton of other jobs out there?