Would you snow please?

When the sound of the gusting wind woke me up at 1 am this morning, I sat up in bed. I couldn’t sleep anymore; the noise was intolerable, like the constant sound of waves hitting a beach. On and on, with no end in sight. My memory traveled back to when we visited a small boutique hotel on the waterfront of Curaçao, where I heard the same rhythm, except now I was in my own flat, 14 stories above sea level.

I looked outside the window, hoping for something interesting. Farsta train station shone brightly. A train left the platform, illuminating its surroundings briefly with the warm, soft, fluorescent light of its windows. As it faded in the distance, dullness returned: an empty car park, empty roads, and dark apartment blocks. Everyone was asleep except me.

I wished it would snow, like last week. The snow didn’t stay, but I was hooked for hours by the window watching the beautiful snow flakes as they fell, as they melted away to nothingness when they touched the road. In May when we moved in, the sales brochure had painted a tantalising picture of how the scenery would look like in winter. The trees were all white, filling up spaces where the roads were absent. On the horizon, there were two gleaming frozen lakes, inviting me to visit. A lovely backdrop that we had fallen in love with.

I have never missed a Christmas in Sweden. Every Christmas for the last three years, I have chosen to be in Stockholm, but every year I have never received a white Christmas. I hate January and February for their abundance of snow, because snow should only appear in December. As a former southern hemisphere inhabitant from Australia, that was what we were missing with our Christmas, we were told. We had the delicious ham, the hearty roast and the bountiful presents, but the Europeans told us, “it’s never the same, because it’s not a white Christmas”. Bloody hell, I am in one of the coldest countries on earth but where is my white Christmas?

The morning came and I walked out of my apartment. The path I usually walked on had turned into a slippery slope, buried deep in snow. I called out for Min’an to take a look, and soon after he came with a red snow sleigh. Very unlike him, I thought. He never fancied the white stuff. Nevertheless we rode the sleigh on the slope, woo hoo! It was only for a short time but it felt satisfyingly triumphant when we reached the bottom. I had not done that in my life ever, I thought.

And I was right – I still had not done that yet in my life. Because it was just a dream. I woke up and sat up in bed again, this time at 3.36 am, just about two hours later. The wind was still howling like wolves. I slumped back to bed, struggling to sleep with all my might.

Would you snow please, Stockholm?

Stuck in Stockholm

The second quarter for 2015 just ended and it’s been pretty chock full for us. After an unsuccessful attempt to get to London we’ve decided to stay in Stockholm for the next few years!

Fresh off the boat

Apart from some certainty about where we’ll be six months from now (we really didn’t know at the beginning of Q2!), it also means we can make some concrete decisions about where we’re staying and working on. There’s no avoiding the winters, but at least it’s sunny outside for now.

Sunny weather outside!

Now that we’ve been in Stockholm for just over 2 years, and likely a few more, we might as well make better use of it. Inspired by Eat your Kimchi, we’re starting a small side blog to write up some of our experiences in Stockholm. Something we’ve affectionately titled Stuck in Stockholm.

Getting to know the people and the places here has not always been a walk in the park, and we’d like to share some of our experiences navigating the foreign landscape that is Stockholm.

This is for you, the new migrant stepping off the boat, ready for danger at any turn. Whether for work, for education, or more commonly as it turns out, for love, you’re ready to roll up your sleeves and do the hard yards to call yourself a resident of the land… at least for a few months.

Check it out, comments are welcome with more posts to come.

We’ve also got our own spot now, so if any of you are passing by Stockholm you’ve got a bed in this part of the world. Here’s a shot of the living room.

Our new living room
Not the most creative bunch as you can tell 😉 Not only does it look uncannily similar to our place in Sydney, it’s even filled with the same things!

Board games
To be fair, they aren’t the same set of games but they will be after our next trip down under.

On the topic of board games, we’ve also put our small boardgame scanning app Gamenauts on the app store, play store, amazon store and more to come. Don’t even get me started on the horrigible release and approval process…or the horrors of how much of a cut they take. >:(

Gamenauts

Much learning here, we’ve actually had the app out on the Google Play store for a while now, but it’s only after Marty spammed a bunch of board game groups on Google+ that we started seeing a spike in numbers.

It’s still a modest number of downloads, and even less in actual revenue. Let’s just say it isn’t enough to cover a decent meal here in Stockholm, but the upward gradient has been steeper than anything we’ve had so far. It’s also hard to describe the feeling you get when you see someone else writing about you, in a different language no less!

I’m going to cut the shameless hawking here and spare you the agony. There’ve been a few more things we’ve been up to though, so stay tuned!

The revival of an old hobby

My phone broke again this morning. It wouldn’t turn on. And this was not the first time it had happened. Minch had to replace the battery just one month ago, and I waited for two weeks for the battery to come, all while using a replacement mobile.

I thought getting home from work would be the most boring ride today. What would I do? My laptop was useless without the internet, which I relied upon my phone to access. As I arrived on the platform, I missed my train, just. The next train to go home was in three minutes.

So, I found a place to sit down and started drawing to kill time. I drew a lot last year, but this year not so much, not sure why. Maybe the negativity I suffered at work has started to affect me long-term. I was drawn to the garbage bin on the platform. It was an easy pick, cylindrical shape at the top, cylindrical shape at the bottom, connected by a rectangular block. Before I knew it, the train had arrived. I hurried into the train and I continued my drawing, this time with different target objects. Everyone is very interesting when you look at them closely.

Garbage bin

Then I heard it, “Enskede Gård”.
I looked out of the window, the announcement lady wasn’t lying, it was the Enskede Gård station.
“Shit”. I hopped out of the train immediately.
I had taken the wrong train. Thanks to the garbage bin I drew. I cursed myself. I had to take a train two stations back to take the correct train. Bah, the returning train would only be there for another eight minutes. Eight minutes! I thought I would be home by now.

I glanced over the railways to the scenery of residential houses around the station. There were lots of apartment blocks, with plenty of greenery surrounding them. I gathered my attention to a park nearby, looking for shapes I could easily draw. My next target object was a playhouse for children next to the sandpit. Drawing the shapes took me just several minutes, and that times goes by very fast, I love it, I was in the zone. I forgot about anything else, and it’s such a distant feeling. I feelit sometimes when I write, but never as intense as when I draw. After I finished, I re-drew the playhouse, this time in just two minutes. This was today’s deliberate practice.

Playhouse

The train carried me back to the connecting station, only for me to miss another train in the right direction to get home. But this time rather than sighing, I knew the drill. I took my pencil out and I drew another target object. The lady was sitting in the waiting area and her jeans had a huge hole that exposed her knee. I was worried that she would think I was creepy, looking at her legs rather intently.

Before I knew it, the right train arrived, and I got home. I had spent a good 40 minutes getting lost on the metro, though it felt really quick.

Minch fixed my phone and by the next day I was back in action without a hitch. Using the internet during the train journey was not going to be a problem anymore, but I will certainly be drawing more often instead.

Last drawing

CS0234: The type or namespace name ‘System’ does not exist in the namespace ‘Windows.’ when running Cordova for WP8

All this cryptic error messages really says is…use the 64 bit version of Windows, not the 32 bit as the cordova docs suggest.

As a tip to prevent much pain, suffering and tears, the Windows Phone emulator will NOT run in in a nested virtualisation environment, at least not when I tried it on Virtualbox. e.g. it won’t run on a mac running Virtualbox containing Windows.

Bootcamp or something similar is probably your best bet for running it on a mac. Or a windows phone device, though Parallels users might have better luck.

Simplest event system you can use with React.js

A common scenario when dealing with React is inter-component communication, particularly when the components do not share a parent child relationship.

For example, consider the case of a context-dependent header bar action that affects the main content window.

<Layout>  
    <AppBar />
    <Content />
</Layout>  

Arguably, there are a number of alternative solutions such as providing a callback to the AppBar, and propogate back down to the content (you can invoke component methods directly via a ref), but we’ll focus on the non parent-child case mentioned in the official docs.

It turns out that if you’re using browserify you already have access to an implementation of NodeJS events, so emit away.

// eventService.js
'use strict';

var events = require('events');  
var eventEmitter = new events.EventEmitter();

module.exports = eventEmitter;  
var bus = require('./eventService');

...
// caller
handleAction: function(arg) {  
  bus.emit('addCard', arg);
}

// receiver
componentDidMount: function() {  
  bus.on('addCard', this.addCard);
}

Closing popovers in Ratchet

Ratchet is a css/js library for prototyping iOS apps. Maintained by Twitter, it looks similar to its more established older brother Bootstrap but is much less mature and has an anemic API.

Simple things like closing its popovers don’t seem to exist. If you need to do this, digging into the source reveals

element.addEventListener('touchend', function () {  
      popover.addEventListener('webkitTransitionEnd', onPopoverHidden);
      popover.classList.remove('visible');
      popover.parentNode.removeChild(backdrop);
});

for the popover backdrop, so doing something like

var backdrop = document.querySelector('div.backdrop');  
if (backdrop) {  
  // sad there's not real way to close this
  // https://github.com/twbs/ratchet/issues/625
  var evt = document.createEvent('TouchEvent');
  evt.initUIEvent('touchend', true, true);
  evt.target = backdrop;
  backdrop.dispatchEvent(evt);
}

to dispatch the touch event was sufficient for my purposes.

See https://github.com/twbs/ratchet/issues/625 for a short discussion on this.

Uncaught Error: DATA_CLONE_ERR: DOM Exception 25

If you’re using IndexedDB in Chrome and getting this exception, AND you’re not using web workers like this StackOverflow question, you might have members of type Functions on the object you’re saving.

See MDN’s article on structured clones for more info on what’s allowed. Also worth noting are that prototype chains and property features are not cloned.

Hope this helps 🙂

Browser storage options, specifically Cordova, Android + iOS

Specifically cordova, Android + iOS

Interesting alternatives:

getBBox returns a 0 sized rect

TL;DR: Your svg has to be visible for getBBox to be useful

While working with d3 recently, I was trying to calculate the width of some elements using getBBox , except it kept returning a 0-sized rect.

It turned out that the svg was being rendered when its parent <div> was not visible. Calling getBBox when the svg is visible gives the right results.

Apparently webkit used to some have issues with this but was patched a long time ago.

Hope this helps.