Switching to Wordpress

For various reasons, I have decided to move my blog to Wordpress.

I have been slightly unhappy with Blogger for a while, mainly due to small annoyances. Also, although I like the theme I have installed here, it has dawned on me that the fonts are not very easy to read (I know, probably easy to fix).

But the main reason for the switch is because I haven't been able to find a way of posting entries from inside Emacs. On Wordpress, this was relatively easy to get working.

I will post an entry on the new blog, describing my experiences with the two services in more detail.

Bye Blogger.

JAOO 2008 recap

So, time for a (late) JAOO 2008 recap. How was it this year?




The keynotes


Unfortunately, the keynotes were clearly lacking this year, but in very different ways.

Monday, Anders Hejlsberg talked about the future of programming languages. Or should I say, the future of programming languages on the .NET platform. For which there is currently support in Visual Studio. Don't get me wrong, I actually like .NET, even though I hate Windows. But for the opening keynote, talking about F#, LINQ and P-LINQ (with the Pascal background intro that seems to be becoming the slightly dull backdrop for Hejlsberg's talks) simply doesn't cut it. And switching to VS three times to do live demos is just missing the mark by a mile. I was very disappointed with this talk, but mostly because I know how brilliant Hejlsberg is, so I expected more than just an MS-centric view of the future.

Lars Bak talked about V8 tuesday. This keynote was a bit special, because obviously it had to be planned some time in advance, and the V8 project was only revealed very recently.

Working in the office next to Lars and the rest of the Google team here in Aarhus, I was very curious to hear more about what they have been up to for the last few years. In that respect, I certaintly wasn't disappointed. The talk was rich on details, so having no experience with VMs (in the V8 sense, not the VMware sense :-)), I was lost at times. But this was no problem, and it was great to hear Lars explain about the challenges they've been facing in creating V8. Also the QnA session was very good.

So I was very pleased with this keynote, actually. But as someone pointed out to me later on, the topic really wasn't keynote material. Interesting as it was, and popular as the topic is, it was obviously only relevant for a fraction of the audience. Nevertheless, I personally enjoyed this one.

Wednesday's keynote was a complete disaster. The otherwise brilliant Guy Steele and Richard Gabriel (who is also very bright, I'm sure) did their "50 in 50" routine, and I have to say that I absolutely loathed every minute of it.

The tagline was something like: 50 remarks in 50 minutes, each 50 words long (if I recall correctly). The remarks were interspersed with images, audio and video clips. The substance of the talk was a tour through the last many (50?) years of programming languages, sprinkled with uber-geeky humour. Definitely not for me, but fortunately, judging from the reaction of the audience, others liked it better.

However, I'm pretty sure noone enjoyed the fact that they went more than 20 minutes over their time slot. Given that the talk was so rigorous in its form, I simply don't understand how this could happen.

The talks


I didn't see as many talks as I would have liked this year, but I did see some good stuff.

Guy Steele gave a great talk on Fortress. Not unlike the one he gave last year (or was it 2006?) but with even more substance. Some of the maths stuff was over my head, but that didn't matter. The important this was that the talk was interesting and really whet my appetite for learning more about Fortress.

Also, Sun ran a great little competition in the exhibition area this year. A guy came around to our booth with 2-page Fortress program that solves Sudoku puzzles in a massively parallel fashion. The challenge was to figure out how many threads of execution are used, and the prize was a Sun-branded USB stick with the latest snapshot of Fortress on it. I still have the program on my home office wall, and when I feel like it, I look over it and understand another little chunk. Unambitious, you may say, but a lot better than putting it away and forgetting all about it.

Wednesday, a guy from LEGO gave a pretty weak talk about a project that actually looks very interesting. They're building a new "robotics platform" called WeDo, which is basically a $30 (IIRC) kit with a few motors and sensors. This was a challenge spurred by the OLPT project, so various measures have been taken to target it at developing countries. For example, the robot is connected to the laptop with a USB cable because batteries may not be readily available. A very cool project, but the presentation was really a drag... For instance, I now know that LEGO uses Perforce for their software projects, and I would have lived happily on without that piece of information.

Lastly, the talk "The lively kernel" by Dan Ingalis was awesome! I urge you to check out this video demo or simply have a go at it yourself. I'm very curious to see what this project might lead to in the future.

The exhibition floor


Again this year, we had a VMware Denmark stand, and we got to show off our software and tell people what we do.

One thing that we all noticed was how much more aware of virtualization everyone was this year. At last year's JAOO, we were very surprised to learn how many developers simple had no idea that virtualization existed as a concept. But this year, it was different. Maybe because we handed out so many VMware Workstation coupons last year ;-)

On the demo side, we had taken the time to get a VMotion setup up and running this year. Two ESX hosts and a Linux VM running some streaming video server being moved between them. And obviously a third machine running Virtual Center and a VLC player showing the streaming video without a glitch as the VM was moved. A lot of the attendees didn't know that this was possible and wanted to know the details of how it works.

Also, we brought our Mac Mini running the recently-released Fusion 2. With all the Google Chrome hype in full effect, it was a lot of fun showing off Chrome running (apparently) natively on the Mac! Of course, it was running in a Windows VM in unity mode, but we did manage to fool a few people :-)

Version 2 of Fusion also adds the ability to run Linux VMs in Unity mode, so we were able to fire up Chrome, Safari and Evolution side-by-side on the (struggling) Mini.

Conclusion


I didn't go to a lot of talks this year (I was at work most of Tuesday) so I shouldn't pass judgment on the conference as a whole. But I do think the keynotes left a lot to be desired.

Also, I think the Trifork team should reconsider the number of tracks on the conference. Judging from various Ruby-related blogs, the trend for conferences is clearly in the direction of fewer tracks (often just one) and much shorter talks.

I think this makes perfect sense. We go to conferences to widen our perspectives on software development in general. And you really don't need 50 minutes to present new ideas or projects. With so many tracks going on at the same time, attendees constantly need to discard a lot of material. This would be less of a problem if there wasn't such a big overlap between the topics of the tracks. But as it is, I think most developers wish they could follow 2-3 concurrent tracks. This leaves you with a constant feeling of missing out on interesting stuff (which you probably are!), and if you're unlucky enough to attend a boring talk, its 50 precious minutes gone.

I think the organizers should consider cutting the number of tracks and the length of each talk in half. The talks should inspire and engage the audience, and this can easily be done in 25 minutes, leaving us with an urge to know more. The success of a talk should be measured by the surge of hits to the project's website after the talk, not by the number of people still present in the room after 50 minutes.

Atheism

No matter if you're an atheist or not, these articles are really worth a read:

When Atheists Attack by Sam Harris, about Sarah Palin. Very well written and definitely thought-provoking, whatever your stance is on politics and religion.

And if there were, what then? by Piers Cawley, about atheism in general. An excellent read, and very much to the point.

I have been thinking a lot about this lately (especially since reading these articles). Unlike Piers, I'm not quite ready to declare myself an all out atheist just yet. Mostly because I'm reluctant to completely reject something I know very little about.

But what I can't understand or accept is the terrible destuctiveness of the way religion is practiced around the world. All religions claim to be peaceful, yet people are slaughtered every day in the name of some religion, and entire populations are deprived of progress because religion is deemed more important than freedom. What is the point?! I should really read more about this and learn.

Watching the news every day nudges me steadily in the direction of atheism. From a distance, religious behaivour looks like madness to me, plain and simple.

Quickly jumping to symbols

This is brilliant.

For a while, I have been using ido to quickly jump between buffers and files by just typing any part of the file/buffer name I want. In fact, typing any sequence of letters narrows the interactive search to candidates with names that contain those letters in that order:


fb -> Foobar, FrancisGailBrown

But for finding method definitions in a big source file, I have always just used isearch. It turns out that there is a better way.

By combining imenu with ido, I can quickly find methods as well:



All it takes is this method in my init.el:



(defun ido-goto-symbol ()
"Will update the imenu index and then use ido to select a
symbol to navigate to"
(interactive)
(imenu--make-index-alist)
(let ((name-and-pos '())
(symbol-names '()))
(flet ((addsymbols (symbol-list)
(when (listp symbol-list)
(dolist (symbol symbol-list)
(let ((name nil) (position nil))
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(addsymbols symbol))

((listp symbol)
(setq name (car symbol))
(setq position (cdr symbol)))

((stringp symbol)
(setq name symbol)
(setq position (get-text-property 1 'org-imenu-marker symbol))))

(unless (or (null position) (null name))
(add-to-list 'symbol-names name)
(add-to-list 'name-and-pos (cons name position))))))))
(addsymbols imenu--index-alist))
(let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names))
(position (cdr (assoc selected-symbol name-and-pos))))
(goto-char position))))



I have bound it to C-t, because I realized that I don't use transpose-chars (or whichever transpose method was there..I don't use any of those, really).

I found this trick on the imenu wiki page.

My first AVR-based project

I have always been fascinated by electronics. As a child, I tore apart several rather expensive appliances to see how they worked. Much to my parents' grief, of course.

However, since I got into software development, I haven't given it much thought. Moving several levels of abstraction away from the hardware, your focus shifts quickly to completely different areas.

But recently, this project caught my attention for some reason. So even though I ended up implementing it completely differently, I couldn't stop thinking about the potential of being able to write code for tiny, cheap embedded processors.

I'm not sure why I have never thought of this before. I have considered writing software for PDAs, but they're pretty expensive, and the platform choices are poor. Windows Mobile is a joke, and Palm OS is not very appealing either.

So I decided to take a big step closer to the iron. Knowing nothing about the state of this field, I simply googled for a few starting points. I ended up buying the very cool USBtinyISP programmer kit (and absolutely enjoyed the process of assembling it).



Also, I got the ATtiny26 development board from Active Robots.



This last item, I have later discovered, is probably somewhat outdated. What you want for electronics prototyping these days is the Arduino.



Anyway, the great thing about the ATtiny is that it's cheap (the processor itself is about $4) and it doesn't consume a lot of power.

OK, so what did I do for my debut project? Nothing very interesting, I'm afraid. I wrota a program that simply morses a sentence using the LED built into the development board. I used the GNU toolchain (avr-libc et al) for writing the program and avrdude for flashing it onto the processor. Works great on both Linux and OSX.

In action, this is what it looks like:



And yes, I realize that the quality of the video is too crappy to distinguish the pulses.

Here is the complete source code for this project (sorry about the formatting):




#include <avr/io.h>
#include <string.h>
#include <stdlib.h>
#include <util/delay.h>
#include <avr/pgmspace.h>

/*
* The morse alphabet.
*
* 0: Short pulse
* 1: Long pulse
*/
const char ltr_a[] PROGMEM = "01";
const char ltr_b[] PROGMEM = "1000";
const char ltr_c[] PROGMEM = "1010";
const char ltr_d[] PROGMEM = "100";
const char ltr_e[] PROGMEM = "0";
const char ltr_f[] PROGMEM = "0010";
const char ltr_g[] PROGMEM = "110";
const char ltr_h[] PROGMEM = "0000";
const char ltr_i[] PROGMEM = "00";
const char ltr_j[] PROGMEM = "0111";
const char ltr_k[] PROGMEM = "101";
const char ltr_l[] PROGMEM = "0100";
const char ltr_m[] PROGMEM = "11";
const char ltr_n[] PROGMEM = "10";
const char ltr_o[] PROGMEM = "111";
const char ltr_p[] PROGMEM = "0110";
const char ltr_q[] PROGMEM = "1101";
const char ltr_r[] PROGMEM = "010";
const char ltr_s[] PROGMEM = "000";
const char ltr_t[] PROGMEM = "1";
const char ltr_u[] PROGMEM = "001";
const char ltr_v[] PROGMEM = "0001";
const char ltr_w[] PROGMEM = "011";
const char ltr_x[] PROGMEM = "1001";
const char ltr_y[] PROGMEM = "1011";
const char ltr_z[] PROGMEM = "1100";

PGM_P alphabet[26] PROGMEM = {
ltr_a,ltr_b,ltr_c,ltr_d,ltr_e,ltr_f,ltr_g,ltr_h,ltr_i,ltr_j,ltr_k,
ltr_l,ltr_m,ltr_n,ltr_o,ltr_p,ltr_q,ltr_r,ltr_s,ltr_t,ltr_u,ltr_v,
ltr_w,ltr_x,ltr_y,ltr_z
};

void sleep_msecs(int msecs)
{
/*
* The argument to _delay_ms must be constant (ie. known at compile-time).
*/
int i;
for(i = 0; i < msecs; i++){
_delay_ms(1);
}
}

void set_led_state(int state)
{
PORTB = (state == 1) ? _BV(6) : _BV(0);
}

/*
* Emit single pulse
*
* Length choices are:
* 0: short
* 1: long
*/
void emit_pulse(int length)
{
set_led_state(1);
sleep_msecs((length == 1) ? 210 : 60);
set_led_state(0);
sleep_msecs(100);
}

/*
* Emit a sequence of pulses, eg. "1000" for the letter "b".
*/
void emit_pulses(char *pulse_str)
{
int pulse_str_len = strlen(pulse_str);
int i2;
for (i2 = 0; i2 < pulse_str_len; i2++) {
emit_pulse(pulse_str[i2] == '1');
}
}

void emit_letter(char l)
{
if (l == ' ') {
sleep_msecs(700);
return;
}

char *buf = malloc(8 * sizeof(char));

int index = l - 'a';
PGM_P p;
memcpy_P(&p, &alphabet[index], sizeof(PGM_P));
strcpy_P(buf, p);
emit_pulses(buf);
free(buf);
}

void morse_msg(const char *msg)
{
int len = strlen(msg);
int i;
for (i = 0; i < len; ++i) {
emit_letter(msg[i]);
sleep_msecs(350);
}
}

void do_morse(const char *msg)
{
for(;;){
morse_msg(msg);
sleep_msecs(2500);
}
}

int main(void)
{
/* Init IO */
DDRB = _BV(6); /* make the LED pin an output */

do_morse("er der mon mere kaffe");

/* Not reached */
return 0;
}



In case you're wondering, the morsed message, "er der mon mere kaffe", is danish for "I wonder if there's any more coffee". Indeed, the first thing that sprang to mind when I finally got the software working.

Nostalgia

Thomas Winding, you will be missed


Not so long ago, Danish author Thomas Winding died, 71 years old.

Thomas was famous for writing a lot of books for children, but even more for reading his stories aloud on the radio. He had a deep, calm voice that was known and loved by all Danish children when I was a child.

The death of Thomas Winding seems to have led to a feeling of "mass nostalgia" in my generation. A Facebook group has been created, and the media has written a lot about how everyone will sorely miss the "soundtrack of their childhood".

This made me think. I'm 33 years old now, and I don't think I have heard the voice of Thomas Winding for almost a decade.

Still, his death is kind of a painful event for me. Of course, I will not miss him as such, but he was a very happy memory of my childhood. So losing him is yet another reminder that I am no longer, and will never again be, a happy and carefree child.

It seems bizarre to feel so sad about the death of a person I didn't even know, and haven't thought about for years. But luckily, I'm not alone, and there is a word for this feeling: Nostalgia.

Feeling nostalgic


According to Wikipedia, the word Nostalgia is of greek origin and refers to "the pain a sick person feels because he wishes to return to his native land".

I think this is a beautiful way to describe a feeling that everybody knows, but which is hard to define. The description is absolute nonsense, I know, but so is the feeling itself.

In fact, I find it highly irrational, especially from an evolutionary standpoint. I mean, what is the purpose of an individual wanting to "return to his home land"? On the surface, it seems regressive and foolish.

However, it is hard to believe that any counterproductive sentiment would have been allowed to survive for countless generations to still be present in the human beings of today. There must be some rational purpose to this feeling, but it eludes me.

If anyone out there knows, please drop me a line.

My father


So, having questioned the rationality of feeling nostalic, I want to convince everyone that I am not a robot.

Three years ago, my siblings and I lost our father. He died of cancer, only 55 years old. Needless to say, this was a terrible time for our family. After three years, it is still hard.

But life moves on, and this is how it should be.

However, life paused for a brief moment when I found this picture on my harddisk.



My father was a man of habit. Every day, he would take his dog for a long walk in the forest. Same route every day. Same sticks that had to be thrown into the water at the same spots on the route along the lake, year after year. He once calculated that he had walked more than a thousand miles on this trail, which is only a few miles long.

Our dog, Luna, was a very loving animal, and she absolutely adored my father. She was half Collie, so the herding instinct was very visible in her behavior. I think this is part of the reason that we loved her so much. She always wanted to keep the family together.

The above picture was taken by me. Luna is clearly worried that I have become separated from the leader of the flock, so she looks ahead to assess the risk.

For me, looking at this 5 year old picture simply defines nostalgia. It forces me to forget the present and focus on the past for a while. Never again will I join my father and Luna for that walk, and my home town seems so far away now.

Cat faucet, crude edition

If you're a cat owner, you know that cats love to drink from the faucet!

Being a cat owner myself, I was pretty excited to learn about this Cat Faucet project by Sixerdoodle Electronics. I have often thought about building something similar myself, but I had never gotten around to it.

However, even though the design of the Sixerdoodle Cat Faucet is very elegant, I find it more complicated than necessary (mainly because they wanted to keep it low voltage, it turns out).

So I started wondering how to build the simplest possible cat faucet. This is what I came up with:


(Open above image, with notes, in a new window)


(Diva enjoying the running water)

The complete list of components:


  • a solenoid from an old dishwasher

  • a movement sensor (the kind usually used to light up a driveway)

  • a few bits of plumbing

  • a piece of gaffer tape to limit the area monitored by the sensor




(Solenoid from an old dishwasher)


(The movement sensor, pointed straight down)

That's it. The flow of water is controlled simply by adjusting the position of the red valve that lets water into the system. The sensitivity and timeout of the sensor can be controlled with small knobs on the underside.

My wife put a little bowl underneath the faucet to allow the cats to drink from a surface of water as well as from the running water. Excess water simply spills down the drain below.

Contrary to the Sixerdoodle design, my cat faucet is not low voltage (it runs on 230V, our mains voltage in Denmark). However, because both components were designed to be safe and withstand pretty rough conditions, this does not worry me at all.


(The finished setup, tucked away under a small shelving unit)


(Obviously, it takes a little practice!)