Sunday, 14-Feb-16 21:31
Vagrant To Go

Quite a few people use Vagrant as their development environment. It provides a nice way to basically package all your dependencies in a neat fashion so that you don’t have to worry too much about installing binaries and versions - no longer do you need to worry about virtualenvs or rvms or how to install a particular database when some of the devs have OSX, others use Linux and some enjoy some brand of Windows. Just say "git clone", "vagrant up" and go. Your editor lives on your regular desktop, and everything else happens inside the Vagrant box.

It’s all good, except for the minor problem known as "filesystem notification events don’t propagate into the Vagrant box" also known as "inotify doesn't work on Linux guest". That means that when you change a file on your host machine, the automatics on the box side don't notice it and don't start a recompile - known as a hot reload - forcing you to recompile manually. There are a couple of ways around this, mostly either by polling actively (which is quite CPU-intensive), or in case of scripting languages like Python, automatically checking the modification dates on each reload. You can also twiddle with vagrant triggers.

However, go (or golang for SEO purposes) is a compiled language, so while there are many hot reload packages, they never see any changes and hence are useless. So imagine my joy when I stumbled upon the vagrant-notify-forwarder Vagrant plugin, which almost automates everything. It installs a daemon on the host side and forwards the filesystem events to the box. You can easily install it with

$ vagrant plugin install vagrant-notify-forwarder
$ vagrant reload

However, it only sends ATTRIB changes to the box. And most golang hot reloaders only listen to changes to the actual file content. But the very responsive Ivan Pusic added a nice patch to his excellent rerun utility and suddenly the world works again. Just add the "--attrib" -flag to rerun, doing something like this:

$ vagrant ssh
% go get
% cd $GOPATH/src/myproject
% rerun --attrib -s *.go


Thursday, 03-Dec-15 19:58
Simple hotkey locking of your Mac

At work, I quite often listen to music on Spotify or iTunes (because of reasons). However, when you have to leave the laptop for just a bit, I need to both stop the music and lock the computer, and it's a bit inconvenient. So I needed a way to make the computer go quiet and lock itself up nicely.

So I wrote this piece of AppleScript, and bound it to Cmd-L using Quicksilver (yes, I know Alfred folks can do this too, but I'm a QS user). Drop it in ~/Library/Scripts/ and bind a trigger key to it in QuickSilve (or whichever tool you prefer). You will need to also set up Keychain Access so that it has a menu item for locking the screen. This works with OSX 10.10 (Yosemite) at least.

#  Tell our noisy programs to shut up
tell application "Spotify"
end tell

tell application "iTunes"
end tell

#  Lock up the screen without going to sleep.  Needs that Keychain Access
#  is set up properly.
tell application "System Events" to tell process "SystemUIServer" to click (first menu item of menu 1 of ((click (first menu bar item whose description is "Keychain menu extra")) of menu bar 1) whose title is "Lock Screen")

Sunday, 27-Sep-15 10:57
Biking in electric mode

One of the great things about living in Helsinki is that we have a really nice public transportation system, which basically means that many people do not need to own cars. Some do, because of hobbies or kids hobbies or badly chosen workplaces, but most people in Helsinki choose to live without a car.

So obviously I live in neighbouring Espoo, where car ownership is the norm. This makes life without a car a bit more complicated.

I’ve so far been fine with bicycling and the use of public transportation, but I’ve recently gotten a bit weary of the fact that the bike travel is a bit of a hassle always. With a car, you open the lock, step in, and drive. With a bike, you first dress up in clothes that you think make you look sexy in a middle-aged kind of way, but which mostly result in spontaneous deaths by laughter by any seagulls you pass. Then you pack half of your stuff in a pannier (forgetting the stuff you’re actually going to need in your other bag that you use with public transport, ‘cos panniers are just impossible to carry and backpacks just make you sweat like the proverbial pig), pull on a helmet and goggles and open enough locks to keep anyone from stealing the building the bike is attached to. Only then can you drive to the office, where you arrive looking like you just went through a car wash that ran on sweat instead of water. Though obviously you’re totally high with endorphins, so you don’t really care about the disgusted looks of you coworkers and just bask on your own righteousness for living maybe two minutes longer again than anyone else.

And the same thing going back in the afternoon, but this time without a breakfast in your belly.

So I started figuring out if there would be an easier way to get my endorphins without being stinky all the time (and streamlining the travel hassle). I figured I would give e-bikes a try.

E-bikes aka pedelecs be cool

For those who do not know, e-bikes (or to be precise, pedelecs) are electrically assisted bicycles. When you peddle, an electric motor kicks in, and boosts the power of your legs. They do not work without peddling (‘cos that would make them electric vehicles, kinda like mopeds, and most of the EU law takes a very dim view on people rolling around with electric unlicensed vehicles), and the max assist speed is limited to 25 km/h, after which all speed increase comes from your own barley engine. But basically they’re the closest thing for an exoskeleton you can buy off-the-shelf these days.

I bought a Staiger Sinus BT-20 from the very friendly folks at Elektrobike (I highly recommend them!) about a week ago, and have been driving now about a 100 km with it during the week.

Roll your mouse over the image for a quick tour of the bike.

It’s, simply put, marvellous.

It turns what was a sweaty run into a brisk stroll. You still have to pump those legs, but it smoothens the uphills and accelerations into what feels like a strong backwind helping you on a gentle upward slope. And you get really, really surprised looks from twentysomethings on their superlightweight fixed gear bikes when you catch up on them on uphills.

Another bonus that I suspected might happen is that it turns out that driving an e-bike cuts about 5 mins on my 30 minute commute. So that’s 10 minutes per day of time not spent commuting. Assume conservatively three times per week, 30 weeks/year turns out to be about 15 hours/year of more free time. Might not seem much, but if I value my free time at say €35/hour, it’s certainly a way to justify myself the higher cost of the e-bike.

What I did not expect was the effect it has on my driving style: when I no longer need to worry about conserving momentum (that is, slowing down because of people congregating on the driveway), I can afford to be a lot nicer to anyone else sharing the road. No need to do human pole slalom, just stop and let the engine worry about bringing you back to speed. Lower the gear, peddle nicely, no sweat broken.

While I do adore the MAMIL -look (Middle-Aged Man In Lycra) as much as everyone, there’s something to be said about the ability to drive in your street clothes. Obviously, wet weather will be a problem, but I got myself a rain poncho from Rose which should solve most of the issues. We’ll see - the Finnish weather will be showing its worst in the next few weeks. But most of the time I can save yet another few minutes by not having to change clothes back and forth.

And yeah, I don’t need to use the pannier anymore for commute: because it’s just a brisk stroll instead of a sweaty run, I can use my regular backpack. So no more of "prkl, left my wallet in my other bag".

Spoiler: it's a bit on the heavy side

What’s not to like? The obvious - the e-bike is bloody heavy. It’s like 25 kg, 10 kg more than my normal bike, and it does show. My e-bike has front suspension, which has come in really handy: the curbs are murder, even though the tyres are a bit thicker than usual for a trekking bike (47/622). If I had to carry it up and down stairs a lot, it would definitely not be my first choice for a bike.

Also, turns out it’s really hard to figure out a place to attach an U-lock on it, since the battery (which is fairly large and heavy) occupies a big chunk of the body triangle.

The range? The range isn’t actually that much of an issue. So far I’ve only charged the battery once, so it’s way better than your average smartphone, but since you can choose the assist power (from “Eco” to “Turbo”) you can pretty much forget about the range. The bike will let you know the distance you can still drive in the given mode, and you can optimise your power use accordingly. The bike comes with a humongous charger you probably wouldn’t like to carry with you (so whether this bike is useful for longer trips is a bit of a question still), but home charging for a few hours is not a problem. And even if the power runs out, it just becomes a regular - albeit a bit heavy - bike.

Get one

Overall, my verdict is: E-bikes are ready for primetime use. Their price will need to drop a bit (don’t buy one with a cheap Chinese battery; you may see very fast degradation) before they become a choice for everyone, but the range is sufficient, the technology is fairly mature, and the weight isn’t a problem for most use. They’ll also be getting progressively better every single year, so the more you wait the better bang for the buck you’ll get, but jumping onto the bandwagon today is already totally fine.

Saturday, 12-Sep-15 13:54
The Great Silence

The more we learn about the universe, the more pressing becomes the question - where is everyone else? Why is this Great Silence out there? Are we truly alone?

One of the possible explanations is the Great Filter, the idea that basically life is abundant in the universe, but at some point some calamity inevitably reaps the budding civilization before it can go multi-planetary and multi-solar. And, based on the imminent climate disaster that we have brought upon ourselves, and the generic amount of nuclear weapons in the world, this could very well be the moment where the Great Filter reaps humanity.

But I started wondering - wouldn’t a culture that would know of its impeding doom at least try to warn others of the same path? Wouldn’t they spend an effort spending their last resources screaming at other nearby planets with high-powered radios, or sending slow spacecraft to other solar systems, just so that others would know they existed and that they would not do the same mistakes?

Wouldn’t we?

So, even with the Great Filter, it’s mysterious that nothing can be heard. A few possibilities come to mind:

  • We could be one of the first civilizations (within our local neighbourhood). So we should go a spread out now before the others catch up.
  • We’ve already passed most of the Great Filters, and we now have the technology to cope with the new ones (Yay!)
  • The typical Great Filter comes so abruptly that there’s little time to react. Like a stray asteroid. But in that case, the climate change wouldn’t be It.

I don’t know. Much smarter people than me have spent a lot of time thinking about this topic. But somehow this thought makes me feel better about everything - it suggests that as long as there’s time, we can cope with the issues at hand. If we were to die out, it would happen so fast that we wouldn’t really know about it.

But let’s still be on the lookout for those warning signals.

Monday, 10-Aug-15 21:53
Kultainen Kuukkeli 2004, final notes


As the husband told the wife: "Yes, I will fix the roof. You don't have to keep reminding me every six months."

So, I delivered the final award of the Kultainen Kuukkeli 2004 blog award contest today to Tomi. He won it for "best hacking", for having a really cool-looking blog already ten years ago.

Phew. It always feels good to check the final box of the todo-list. Even if it takes ten years.

Private comments? Drop me an email. Or complain in a nearby pub - that'll help.

More info...  
"Main" last changed on 10-Aug-2015 21:44:03 EEST by JanneJalkanen.

My latest photos