# Overdrive

My brain is in overdrive mode again. I hate it. It makes me quite unproductive. I hate it when I’m unproductive. This post is a brain dump in bid to win my productivity back

I spent the early part of the day editing my books – pretty good effort with 1 chapter left to go for basic editing. Future edits can be done once the books have been published.

The rest of the day was spent with my brain in overdrive. No idea what caused it. Perhaps the increased sugar intake due to ingestion of carbohydrates. Either way I am overthinking the smallest of things.

The afternoon was spent evaluating a potential consulting gig. A yes/no thing took me more than 5 hours of deliberating. It was an astrophysics based statistics consulting, but I wanted more information. The domain specific knowledge usually helps me with decision making in any statistical analysis. I didn’t have enough trigonometry knowledge to take up the gig (well, I could do the statistics part, but not knowing the background of the problem makes me a poor problem solver). I should have rejected that outright. But I spent 5 hours deliberating on it.

I spent time brushing up on basic trigonometry, and then the ideas started flooding in. Maybe I could do this! Maybe I could do that! I could not calm my brain down. Maybe because it’s a Friday. I said no to the consulting job.

Then I had dinner. The food was okay. We had desserts. I recalled why I don’t actually have a food review blog – I could not stop mentally criticizing everything I ate. I deconstructed everything in my mind, down to its basic ingredients, and would be mentally telling myself how to improve textures, tastes and flavours.

One particularly sticky idea that I had was creating a milk that tasted like chocolate. By that I mean, normal looking white milk, except it was a chocolate milk. I felt like I had to go home to try. I didn’t get the chance to.

Brain on overdrive, I started overthinking everything. I went to the supermarket to pick up grapes and fruit. I thought about a joke about Abelian grapes and started chuckling to myself. Partner thought I went a little nuts, so I told her. She didn’t find it funny. Told the joke to 3 other people. Nobody found it funny. Told a number of other jokes that nobody found funny.

I started wondering about the concept and nature of humour and what makes people laugh. Clearly not me. Then I recalled the stereotype people laugh at. The Big Bang Theory was one of them. I used to like it a lot. Then I realized that you were supposed to laugh at the characters, not with the characters. Now I just watch it because I had followed it for 7 seasons so far – the sunk cost fallacy clearly affects even my currently hyperrational state of mind.

I cannot shut off. I am so tired. I know a few things will shut me off – movies, or drugs. Even with movies I don’t seem to enjoy them as much as I used to. I overanalyze every frame. I overanalyze story structure and see twists coming a mile away. I overanalyze cinematography and colour grading to get a sense of things. In the past this used to be subconsciously done. Now it’s active and conscious. It’s tiring.

So very tiring. Before writing this post, I sat in bed wondering how Superman would navigate given that he has just learned how to fly. Clearly navigating the skies by ground based landmark is one way, but then the vivid scene of Superman flying across the African savannah breaking up herds of zebras kept playing in my mind. It was a wonderful scene but it raises questions about how Superman navigates while flying. Birds can sense magnetic fields in their beaks. Can Supes do the same? Perhaps he goes home by doing the Christopher Reeve thing – flying to low earth orbit and re-entry. But how would he deal with the relativistic effect? Assuming he has a superior sense, he would definitely sense the difference.

By then it was obvious I needed a brain dump. My laptop is closest, so my blog is my tool. These things are running in my head all the time. I can’t sleep nor can I be productive. My thoughts branch out way too quickly and way too often now. I don’t really feel like sedating myself, and I don’t do trees alone, nor do I want to given my hyperactive state right now.

I’m just so tired.

# A Funny Thing Happened On The Way To A/B Testing

TL;DR: I split tested the titles of my book: Here’s what happened

So, if you were following my blog (thank you to the both of you), you’d know that I’ve been writing a book on the quirks of JavaScript. I split tested the book across two titles: Underhanded JavaScript: How To Be A Complete Arsehole with Bad JavaScript Code; and JavaScript Technical Interview Questions. This is the story of the twists and turns and missteps that happened when I wrote the book.

# Rubber Ducky Debugging

Oh wow, I’ve just had my first “satori” experience of rubber ducky debugging in a very very long time.

I first tweeted that I ran into a bug in Go, where upon running my code (with go run):

I had a problem where when I ran the same code multiple times, there would be occasions where the program panics. It panics about 40% of the time. And I thought it was a problem with the compilation process.

This then led to a series of conversations between me and the always-helpful Dave Cheney. He led me down a different path of debugging – instead of using go run, I compiled and ran the executable multiple times. The panic happens about 40% of the time again. This ruled out compiler problems.

It ended with him suggesting I email him:

I had rather wanted to get on with my work and not spend a lot of time debugging this. So I sat down and wrote an email and described the problem. The more I described the problem, the more I got the feeling that I may have had everything I thought to be wrong. Until I wrote this line:

…a JSFunctionObject is created, and the pointer is placed in the FnHead node in the AST as the AllocatedValue.

Parts of the SSAForm generator actually accesses the AllocatedValue in the AST while the pointer of the JSFunctionObject is concurrently being set in the AST…

And then it became clear to me what the problem was. VERY VERY clear. I hadn’t even copied and pasted the snippets of code. My design of the program was wrong. And I know how to fix it.

I’m just wow-ing at the fact that the last time I had such a profound satori experience from rubber ducky debugging was years ago, when I was fixing up a machine learning deployment, and I had to explain the bug to someone who had completely no idea about anything programming related. I had to use very simple words and suddenly, it made sense. The same feeling was felt today, albeit with more Go-specific jargon.

I guess sometimes putting your code into english words makes a whole lot of difference.

# What Every JavaScript Developer Should Know About Floating Point Numbers

After I gave my talk on JavaScript (really, I was there trying to shamelessly plug my book – Underhanded JavaScript and its alternate title: JavasScript Technical Interview Questions), there was a Q&A session. I could answer most questions, but Khalid Hilaby asked me a very interesting and quite general question on JavaScript number types. He had simply wanted to know more about floats in JavaScript and why they act so strangely. While I could answer the question, I felt I didn’t answer it well enough. I loaded my article on Pointer Tagging in Go to explain the structure of a floating point number, explained a bit on floating point arithmetic, and how in the past they had to have special CPUs for floating points (FPUs)[1], and then sort of meandered from there.

Now that I am back in Sydney and well rested, I thought I’d give the question a second try. The result is the article – What Every JavaScript Developer Should Know About Floating Points on Flippin’ Awesome. This is the full unedited version before I edited down for length and appropriateness for Flippin’ Awesome.

1. [1] Nowadays they’re all integrated

# You Should Roast Your Coffee In Two Stages (Now Comes With: OpenCV Tricks!)

If you follow me on Twitter (and you should), you will know that since about 3 months ago, I started roasting my own coffee. Yes, my coffee madness has culminated over the years to this. This was my first roast:

Since then I have roasted 16 batches. The variables I vary are: temperature, time, pre-roast mass, and technique. I use a regular $10 popcorn popper from KMart to roast my beans (I originally wanted to purchase a Behmor, but I decided that I should stay lean while learning how to roast coffee) – and I have a thermometer to roughly gauge the temperatures of the popcorn popper. Eventually I’ll hook the thermometer up to an Arduino, but that’s a story for another day. Despite all the controls, I had problems with my roasts. They were okay to drink – not as bad as buying supermarket coffee, but they weren’t excellent. The main problem was consistency. My roasts were not consistent – some beans were darker than the others. Here were the factors that caused the beans to be inconsistently roasted: • Different sized beans – Can’t do much here. • Uneven heating – various causes: • Popcorn popper too hot • Popcorn popper doesn’t agitate the beans fast enough (too heavy? too light?) • Popcorn popper doesn’t agitate the beans randomly enough • Location of beans in popper I eventually narrowed it down to the fact that the popcorn popper was too hot – it burns some beans before they could be agitated out. In fact, after the first two throwaway attempts of the roasting, I realized that 7 minutes or so in a popcorn popper as recommended by amateur roasters on the Internet would just burn my beans. I did a quick lookup, and true enough, most amateur roasters on the web are Americans (or live in America). Are American popcorn poppers different? Continue reading # The Switchless Switch In my previous blog post about why a kettle costs so much, the one statement that perhaps riled the most people up is where I said Tesla Model S’ touch screen control panel was a stupid idea. In fact, the link to the Model S control panel is amongst the top most clicked links out. I do think it’s a stupid idea, but I must disclaim that I have never driven a Tesla, so I may be talking out of my ass based purely on logical reasoning and not a practical experience[1]. The logical reasoning goes something like this: I am driving down the road at 110 km/h. My eyes are on the road, as all safe drivers do. The radio station suddenly plays Justin Bieber[2], and the car gets cold suddenly because Bieber is a witch. I want to: a) change the current radio station; b) raise the temperature of the vehicle interior. But first I have to go to the media control app. Then I need to change my media playback from a radio station to a Spotify playlist containing all my favourite Tchaikovskys. Then I need to access the climate control app to raise the temperature by a few Celcius. The question is this: How many times have I taken my eyes off the road, and how long for each time? Continue reading 1. [1] P/S: Tesla, come to Australia already. 2. [2] I’m only using Justin Bieber as a punching bag because everyone uses him thusly. I actually have no opinions on popular music given that the music I regularly listen to are dated to 300-400 years ago # Javascript: Wat, Again I gave a talk on Javascript recently at Javascript.my‘s unshift() miniconf in Kuala Lumpur. After regretting giving many talks without a recording to track my performance improvements when giving talks, I decided that starting this year, I would record and transcribe my talks. Here’s the first one for 2014. The slides are embedded here as well. I had originally planned to record my talk and use an automatic transcriber to transcribe. But the recording quality was indeed quite poor as my phone battery was running out. I had to use Audacity to clean it up quite a bit. And despite that, automatic transcription with OS X’s Dictation didn’t work as well as I expected it to. Anyhow, here’s the transcription of my talk. A lot of bits were filled in and edited (I really have a lot of uh, and ums when I speak) as the recording got quite garbled as time went on. Towards the end it was a totally unrecognizable warble. I was scheduled to give a 30 minute talk but I ended up talking for about 50 minutes. The last 20 minutes are not transcribed. Continue reading # Why Does A Good Kettle Cost$90+?

Yesterday morning I woke up to a house without electricity – that meant I woke up in a puddle of sweat because the fan was no longer turned on. It turned out that my housemate, while making coffee, had tripped the mains of the house. The kettle had caused the trip. It was no longer safe to use the kettle and so I had to buy a new kettle.

# “I Should Get A Tablet”

“I should get an iPad”, I woke up this morning with that thought in my head. It was a strange thought to wake up to, and so I gave it some thought. If this question was asked a few years ago, I’d have said yes, and promptly acquired a tablet. But now, in 2014, I seriously questioned the need.

I am no stranger to living life with a tablet. A few years ago, I had an experimental run with an Android tablet and briefly, an iPad 2. These eventually fell into disuse. It didn’t change my life much. It was a curious thing though – the tablet changed the habits of people I know. I had felt a tablet didn’t add much to my life.

Then I started to ask why. I looked around at the people around me who use their tablets on an extremely regular basis and did a quick tally of what they do with it. The people I know who regularly use their tablets watch a lot of videos on their tablets – news, talk shows, documentaries, anime, and the like. They also read a lot of stuff on their tablets: buzzfeed, 9gag, reddit, pocket/instapaper, manga, comics and the like. Lastly, they also play casual games on it like that word game where the aim is to pick up words as quickly as possible, or the one where you run and collect coins. I then recalled what I did when I experimented living with a tablet – reading was mainly it. There was also the occasional Jetpack Joyride or Fruit Ninja of course, but for the most part it was reading reddit, digg and hackernews. The Android tablet had quite a terrible experience if I recall correctly, and by the time I played around with the iPad, my habits have changed.

This was where I realized that I don’t need a tablet. Because of late, I have not been doing much of the above – watching videos, reading news or playing games. In fact, my habits have changed a lot over the years, and I’m not sure what to make of it. I started tracking my productivity in 2008, mainly with RescueTime (there was a period where I fell back to manual entry with a spreadsheet). In 2008, my average annual productivity was at 42. By 2013, my yearly average productivity was 72. This year I aim for much much higher levels of productivity.

Another comment that came to mind was a comment my partner made while at a restaurant waiting for food. She had mentioned if it were a few years back, I’d be obsessively reading reddit or hacker news or twitter on my phone while waiting for food. I simply… stopped doing that. Though I have no proper idea why, I have a feeling that was the same reason why I wrote The Slow Web movement manifesto.

Perhaps then, I figured, that tablets don’t fit into my lifestyle because I’ve moved from a primarily consuming lifestyle (consuming media, games, etc) to a primarily producing lifestyle (I started writing more code, doing more statistical analyses, and hacking hardware and bioware for fun). But the counter argument to that is that you can use tablets for productivity, which was why the Surface Pro was such a big deal (let down only by the inability for me to install Linux on it without serious work).

And so I’m back to square one. Tablets don’t seem to fit into my life. I have no idea why. I often wonder if it’s because I’m becoming older and more resistant to change. But for every argument of that, I seem to have a counter-argument. I think I am fairly cutting edge when it comes to new technology – I have played with most new technology and new gadgets. For example, I can see more use with a 3D printer than I can with a tablet. But both are not relevant enough to make it in my life to be used on a regular basis.

I was excited about drones about 2.5-ish years ago, when I had planned to drive into the outback to release a bunch of perpetually floating drones. Last year, drones and UAVs really took off, and all I could think of was “meh”. I could not even muster a single bit of excitement when my friends finally started talking about it. Am I becoming too cynical? Or just growing old and cranky?

# What I Did When Hacker News Went Down

So… Hacker News went down for about a day. I lost my main source of procrastination (reddit contained all purple links). So what did I do? I got productive. I wrote about 20% of a book on Javascript.

You should register your interest for Underhanded Javascript, Or: How to be a Complete Arsehole with Bad Javascript (there’s an alternate title that I’m considering: Javascript Technical Interview Questions).

Here’s a quick blurb of the book:

Javascript is a weird and wonderful language. However. there are often more warts though, and they often remain unexplained. If anything, Javascript does not follow the principle of least surprise. If you have ever seen WTF-worthy Javascript code (and any Javascript dev would have seen at least one), this book is for you. If you were surpised with the result of a particular piece of code, and wondered why the results are what they are, this book is for you. If you have ever wondered why [0] == 0? Why "true" == true returns false then this book is for you.

In this book I go through ~15 examples of crazy Javascript that would make anyone go “WTF??!”, examples such as:

• Why certain Immediately Invoked Function Expressions don’t work?
• Why in some contexts, commas act funnily.
• Why in some cases newlines act funnily.
• Why in some cases, Google Chrome appears to support block-level scoping without ES6 syntax
• Why truthy values are not true, and why falsey values are not false
• What is foo)(
• And many more

I go through these examples, and in a tongue-in-cheek manner, suggest ways to wreak havoc on the unsuspecting. I for one do not actually condone such behaviour. However, all the examples in this book, I have actually seen in real life, and have often cursed the arsehole developers who wrote them. The actual main aim of this book is to help write better code by showing the obvious pitfalls that you may find when debugging other peoples’ codes.

This book assumes you are already an intermediate-to-advanced frontend or backend Javascript developer, and is considered to be light reading. Early reviews have compared it to a light-hearted Programmng Pearls for Javascript developers. This author thinks it’s more like Programming Turds, but okay.

I expect to finish this book by 24th January 2014. Preview copies will be out on 25th, and it will go on sale February 1.

## Update

The name of the book has changed to Underhanded Javascript. It was formerly called Javascript Oddities. The subtitle of the book remains the same.