Eat, code, love.

Hi. I’m Fredrik Appelberg.

Busy playing Hearthstone

So yeah, one reason I haven’t blogged or done any OSS work recently is I’ve been playing Hearthstone obsessively. I installed it with some trepidation and immediately got hooked so hard it is kind of scary. Now I can’t get enough. I read the blogs, watch the streams, follow the drama.

I’m strictly a casual player, and I’ve promised myself I won’t spend any actual money on this game. So in order to beef out my collection I’ve been grinding the Arena for the better part of two months. The Arena is pretty fun, as you get to play around with a lot of cards you wouldn’t usually get your hands on. It’s also punishing, as you really need to rack up those seven wins in order to recoup your gold investment. Last week I decided enough was enough, and switched to playing ranked games.

This season I was toiling away at level 20 for quite a while playing different decks, but then made a conscious commitment to learn the Shaman Way. Shaman is good for casuals like me since you can put together a solid deck out of just commons and rares, and it will both be fun to play and have a decent chance on the ladder. Playing Shaman correctly isn’t easy though; you have to pace yourself and learn when to strike with Lightning Storm, when to unleash your Feral Spirits, and what to hit with your Earthshock. And most importantly, when to hold back and just play a totem.

You also need to think hard about the mana curve. Despite being an all-round awesome card, I realized Chillwind Yeti had no place in my deck; on turn three I usually play an Overload card, which ruins turn four. After dropping the yetis, and a few other tweaks I was shocked how good the deck was doing. I went on win streak after win streak and hit rank 9 today. My one to two hours of game time a day isn’t enough to take me to Legend, but it was pretty sweet to at least break single digit.


My first board

I’m immensely proud of the fact that I soldered together my first prototype board last night. It holds two DS18B20s; one naked sensor soldered straight onto the board and one on a waterproof cable that I’ve hung out the window. This lets me measure current indoor and outdoor temperature.

The board is connected to my Raspberry Pi, where a node.js program using sensorjs is regularly sending the sensor data to a TempoDB database.


pi

Hardware is hard

Where I live there aren’t really any options for electronics shopping, so I was resigned to do it mostly through mail order. Fortunately I discovered that Kjell & Co., which is probably the closest thing to Radio Shack we have in Sweden, not only carries a lot of Arduino stuff, but also has an shop in the next town over (LuleĆ„, about 50km away).

So I got myself a soldering station, some lead-free solder1 some sensors and grab bag of diodes, resistors and cables to play with. It must be something like 25 years since I last had a soldering iron in my hands, but putting the T-cobbler together I all just came back to me. Even the smell was exactly as I remembered it.

I had some problems getting the DHT11 sensor up and running. All the examples I could find had a four-legged sensor, but mine came pre-mounted on a board with only three. Also, the configuration of the legs had been switched around. That one took some figuring out.

The DS18B20 however, just plain refused to show up as a device in /sys/bus/w1/devices. I tried everything: reflashed the SD card, checked the kernel messages, double-checked my connections (twice), moved things around on the bread board in case there was a break (which incidently there is; the vertical strips break in the middle, but this didn’t affect my wiring) and tried every combination of power and GND I could find on the breakout board in case I had done a bad soldering job (which I hadn’t). I did countless reboots. Still nothing.

I had just about written that sensor off when I discovered that the pullup resistor2 I’d used wasn’t yellow-purple-red as specified, but yellow-purple-yellow. 470K instead of 4.7K. Oops.

Hardware is hard.


  1. Which everyone seems to think is terrible, but I haven’t had any problems with. Yet.

  2. I confess I have no idea what a pullup resistor actually does.


Hello, World

Since I pretty much do node.js full-time nowadays, I was curious if I’d be able to run it on my Pi as well. Turns out that’s no big deal; there are binaries available for download so you don’t have to go through the hassle of compiling (which I hear can take quite some time).

Interfacing with the PiFace is another matter. There is a module called piface-node, but I couldn’t get it to do anything, and looking at the source code I could see that it was a bit too low-level for what I wanted to do. However, I did find a C library called libpifacecad, and started hacking to see if I could write a node wrapper around it.

After a few evenings worth of work I am at a point where I can read the sensors pretty reliably and writing to the screen somewhat less so (it works maybe one time out of three). That’s not the fault of the underlying library though, it seems pretty solid. Rather, I suspect there’s either a race condition somewhere (possibly), or I’m making assumptions about C++ memory management that’s not entirely true (probably), or I need to rethink how to do I/O in the node.js event loop (almost certainly).



The Joy of Hardware

Last year Jfokus ran an embedded systems track alongside the main conference, and this was met with considerable enthusiasm. It was a friendly refuge from corporate keynotes and enterprise bloatware seminars, a place where you could escape the buzzwords and marketing people. I discovered that the Raspberry Pi was an actual thing that existed and could be ordered from the internet, and within 60 minutes I had done just that.

Apart from putting together the odd PC back in the late 90’s, I’m generally clueless about hardware. I don’t know what the state of the art for RAM or CPUs are nowadays; in fact I don’t even know how many cores the MacBook I’m typing this on is running. Hardware is a nuisance; the problems that interest me all lie deep into software country.

However, the Raspberry Pi has awakened my curiosity for circuit boards, ports and capacitors. I want to learn about microcontrollers, I want to find out how GPIO works. God help me, I want to solder.

Karin from r-pi.se had a table at the conference, and seemed to be doing a brisk trade. This photo was taken during a lull in traffic, but usually it was so crowded you couldn’t even see the table.

I couldn’t resist getting a PiFace board; I’ve been wanting to add a display to my pi as I tend to run it headless and it would be nice to have some way of displaying status information. And adding a wi-fi dongle seemed like a good idea for a machine like this.

Admittedly, these are toys. Pure indulgence, a guilty pleasure, as I still don’t know what I will do with the Pi. It will be interesting finding out, though.


Emacs Protip: org-mode

Man, where do I start? org-mode is Emacs’ Killer Application. It started out as an very capable outlining tool, but has grown and mutated and now people use it for time management, blogging, presentations, spreadsheets, GTD, you name it. Org-mode is the reason I returned to Emacs after several years as an Eclipse refugee. I needed a system for handling my ToDos, and after hearing good things about org-mode I installed Emacs again and gave it a go. And here I am several years later and I pretty much live and breathe Emacs now.

In other words: if you haven’t tried org-mode, you’re probably missing out. Here, have a look at this screencast. It’s short and sweet and you know you want to.



Emacs Protip: ido-mode

If you are using emacs for anything more involved than editing config files every now and then you owe it to yourself try out a productivity enhancer like ido-mode. It lives in the minibuffer and provides way better completion for file names, emacs commands, buffers, you name it. Seriously, check it out if you haven’t already.

In all fairness, I should probably point out icicles as well as it seems to provide much of the same functionality as ido-mode. But since I’ve never used it I can’t really comment on it.


My best friend

My best friend was a sometimes melancholy brown cat called Yojimbo. That wasn’t his actual name, but it was the one that stuck in my head as we pulled into the driveway to collect him. He was twelve weeks old.

We took him to the summer house. This was the first time in his life he had been outdoors. He sat petrified beside me on the porch for fifteen minutes before demanding to be let in again.

When my best friend was six months old he decided to leap out into a stairwell, plunging two floors and landing on concrete. I will never forget that moment. We took him to the vet, worried about concussion or internal bleeding. She said he had bruised a toe, but that was about it.

My best friend caught a cold, which developed into a nasty cough. It never seemed to get better. Turned out it was asthma. Turned out it was treatable. Two times a day we helped him breathe into a special inhaler. If we were late, or forgot, he would gently remind us.

My best friend had faults. He was a coward, but despised weakness in others. He could be downright mean to other animals. He methodically destroyed our sofa. But we loved him, and he loved us.

He was in an accident and crushed his paw. A very talented surgeon put everything back in place. He wore a cast for two months. Every ten days we would get in the car and drove for 90 minutes to get his foot X-rayed and the cast changed. We went to physiotherapy and did exercises. He didn’t understand, but accepted it. He was three years old.

We moved to another town. Our new place had a garden. My best friend would spend hours lying in wait under the big fir in the back. Once he was chased by a Rottweiler, and was gone for four hours. I wondered if he would find his way back home.

My best friend had an enemy. A large red cat that lived three houses away. They had a huge fight in our garden shed, and then a fragile truce.

Our oldest cat got very ill. One day we had to take her to the vet and she didn’t come back with us. My best friend was upset, and searched for her everywhere. We cried often that summer.

I would go away on business trips. When I packed my bags he ran away and hid. He hated goodbyes. When I got back I was ignored at first, then quickly forgiven.

My best friend got constipated. We tried laxatives and massage. He wouldn’t eat. He grew weak. Again we took him to the vet. Turned out it was a tumour. Turned out this time there was nothing we could do for him. My best friend died on the operating table. It was a very bleak february. He was just about to turn six.