Polyglot developer, geometric tessellation fan, ambient DJ.

Because I always forget this, I’m putting it here:

UPDATE persons
  address='Nissestien 67', city='Sandnes'
  last_name='Tjessem' AND first_name='Jakob'

October 4 2011, 11:10 PM  by David Parr


  1. Make important things big and unimportant things small or remove them.
  2. Keep removing unnecessary stuff until you’ve got a simpler message.
  3. Group things together that are related.
  4. If something needs to stand out from the rest, make it different somehow.
  5. Pick a typeface that’s appropriate for the task at hand. If you don’t know how to do that, then choose an undecorated sans-serif. If you don’t know what that is, use Helvetica.
  6. Group things in categories.
  7. Put space around things that need to be apart from the rest

I think I’ll keep adding to this. They seem like good principles.

November 1 2011, 10:27 PM  by David Parry


January 11 2012, 3:02 PM  by David Parry

EventMachine + WebSockets

This is the notes from a talk I gave at #rorosyd on the 10th of January 2012.

The demo code is available at: [][]

So, what’s EventMachine?

  • Reactor pattern
  • Extremely high performance
  • Doesn’t need threads, concurrency
  • Addresses the C10K problem
  • Callbacks
  • Fast, low memory overhead

EventMachine supports lots of protocols!

There is a great list of currently implemented protocols at which includes:

  • HeaderAndContent
  • SMTPServer
  • Stomp
  • Socks4
  • ObjectProtocol
  • SASLauth
  • LineAndText
  • LineText2
  • HTTPClient
  • HTTPClient2
  • AMQP
  • MySQL
  • SMTP
  • Postgres
  • MemCache
  • XMPP
  • DNS
  • PowerDNS
  • ICMP
  • XML Push Parser
  • Redis
  • MongoDB
  • CouchDB
  • Beanstalk
  • SNMP
  • HTTPRequest
  • HTTPServer
  • PubSubHubbub
  • Proxy
  • WebSocket
  • SMPP
  • RPC
  • IRC
  • Spec
  • Cassandra
  • Thrift
  • Solr
  • Syslog
  • Amazon S3
  • RServe
  • SSH

How to learn about EventMachine?


EventMachine Introduction

Example of a Trivial Telnet Server

require 'eventmachine'
class Echo < EM::Connection
  def receive_data(data)
end do
  EM.start_server(“”, 10000, Echo)

So, what’s a WebSocket?

  • Used for “push”, real-time bidirectional updates
  • HTML 5, proposed RFC, too.
  • In all modern browsers Chrome Safari, Safari Mobile Firefoxx but NOT Android browser (FFS! Why?) ** IE 10, but not IE 6-9 (who cares!)
  • iOS native library + elsewhere
  • Combining EventMachine + WebSocket = em-websocket

Where would I use it?

  • Chat
  • Multiplayer Games
  • Real-time dataviz
  • Real-time news feeds
  • Real-time anything

Trivial WebSocket server

require 'eventmachine'
require 'em-websocket'

conf = {:host => “”, :port => 8080} {
  EventMachine::WebSocket.start(conf) do |ws|
    ws.onopen {ws.send "Hello Client"}
    ws.onclose { puts "Connection closed" }
    ws.onmessage {|msg| ws.send "Echo: #{msg}"}
end }

A Less Trivial example

So, I wanted something to demo that wasn’t trying to do to much but demonstrated the real-time nature of WebSockets, so I built this little socket_demo site:

  • Sinatra serves HTML, JS (CoffeeScript), CSS
  • Running an EM-WebSocket server
  • Each guest decides whether a block is green or red (default’s white)
  • Joining/leaving adds/removes blocks
  • New guest gets snapshot of world

Useless, but non-trivial!


Assign an id to socket/guest

EM-Websocket Server:

class Demo constructor: –>
    if WebSocket?
      window.socket = new WebSocket("ws://")
      window.socket = new MozWebSocket("ws://")

Register ourselves


window.socket.onopen = –>
  window.socket.send JSON.stringify({kind: “register”})

EM-Websocket Server:

socket.onmessage do |msg|
  puts "Server Received #{msg}"
  id = @sockets[socket][“id”]
  incoming = ActiveSupport::JSON.decode(msg)
  case incoming[“kind”]
    when "register"
      ## Send “add” event to everyone

EM-Websocket Server:

def send_to_all(message) @sockets.each do |destination|`


window.socket.onmessage = (mess) –>
  data = jQuery.parseJSON(
  switch data[“kind”]
  when "add"
      window.add_player data["id"], data["color"]

Send click events

$(“#red”).click (e) => window.socket.send JSON.stringify {kind: “update”, color: “red”}

$(“#green”).click (e) => window.socket.send JSON.stringify {kind: “update”, color: “green”}

Server gets a message

socket.onmessage do |msg|
  id = @sockets[socket][“id”] incoming = ActiveSupport::JSON.decode(msg)
  case incoming[“kind”]
    when “register”
      if incoming["color"]
        color = incoming["color"]
        message = {"kind" => "update", "id" => id, "color" => color}
        @sockets[socket]["color"] = color

Live Demo

Then I gave a live demo where I used my laptop as an unsecured base station, and people connected to it with their iPhones and started clicking on the red/green buttons:

wifi: suranyami (no password) url: test.local:4567

How to do testing with EventMachine?


This demo code viewable here: [][]

September 11th, 2013 2:19pm


I was into disassembling old TVs for electronic parts in high school. One day I bought a huge old 1950s unit (broken) at a flea market for $1. It had a 1 Farad capacitor in it about the size of a tin of peaches. Our school library had recently been re-carpeted with nylon carpet that generated epic levels of static charge on cold, dry days. So I used to scuff my feet around the library holding onto one of the terminals of this giant capacitor, then approach a victim and give them my “Star Wars Emporer” electric shock treatment.

A few years ago a colleague did some quick arithmetic and suggested that I may well have been approaching an amount of current that could have caused heart failure. Woops.


So, today is day 2 of me making music with my groovy little setup consisting of:

  • Korg SQ-1
  • Moog WerkStatt Ø1
  • Logic Pro X
  • PreSonus AudioBox iTwo

My soundcloud account here:

Using mono mini-jack cables, connect the following:

  • Korg CV-out to Moog VCO-Exp-In
  • Korg Gate-out to Moog Gate-out (Go figure!)

Even though the gate-out to gate-out thing is the only known (and not officially recommended) way to trigger the Werkstatt, it only really works when you also hold a key down on the Moog.

The first problem I encountered was synchronization. I recorded a bassline, but then tried to add a drum track to it. Since the analog synth had nothing to do with Logic, everything was out of sync.

Because I’m using the Korg SQ-1, though, the solution is remarkably simple:

  • plug the Korg into the laptop via USB
  • set Logic Pro to Transmit MIDI Clock, MMC & MIDI Time Code to all MIDI devices

Now the sequencer is in-sync with Logic. Yay!

Next challenge: the SQ-1 has an in-built MIDI-to-CV/Gate capability. Use that for fun & profit!

Extra note: Gadget love

I have not felt so much fun, expansive possibilities with a piece of hardware in decades. I distinctly remember the times I was blown away by what we can achieve with electronics:

  • When Stephen Smith and I convinced the University of Queensland Psychology Department to let us use their Fairlight CMI in 1982 to make some pretty cheesey pop songs, whenever they weren’t using it.

  • When I played with an Apple Lisa for the first time. I went to print something and it said “Is the cable connected?” This was completely new & revolutionary.

  • Using MacPaint/MacDraw/Adobe Illustrator/Adobe Photoshop/Pagemaker for the first time.

When Stephen Smith & I used to play with electronic instruments in the 80’s, it was a labour of love. We made drums out of bits of old rubber stretched over wooden frames, with crappy dismantled earphones as input devices, processed by Schmidt triggers that we got as free samples by pretending we were an electronics OEM called “DaveTronics Pty Ltd” despite being 14 years old. The great thing about this was working out how much can go wrong just making some noise.

I loved that time. But I love being able to twiddle with sound in the ways I always imagined I could.

I remember having a very heated argument with Stephen because my favourite setting on the Roland SH-101 was “Attack: 0, Decay: 0.001”. It was a great little CLICK sound. What could that click sound have become with a cheap hi-res audio interface, crazy-ass effects, and plugging it into a wicked, patchable analog synth? We may now know.

PS: Stephen Smith, please talk to me! I know it’s hard, but I think I’m your oldest friend and I miss you. PPS: Stephen & I are on speaking terms, nothing bad has happened, it’s just he’s a bit hard to get hold of

January 2nd, 2016 10:28pm


We were inside a Matrix-like simulation of reality.

Our goal was to explore a new planet and colonise it. The new world was arcane and beautiful in its oddities, lakes of flying fish, tall spires where huge elephantine pterodactyles nested.

Soon after arrival, we laid plans, and began construction of towns, cities, farms, houses.

As we began working, there appeared a group of aliens, different from the native fauna. Their actions seemed to be undoing some (but not all) of the actions we were taking.

Then a crop of obstructions and annoyances started swirling around us. Landscapes transformed, people would break out in hives and spots, swarms of bees would obstruct our paths.

Some sought to lash out at the newcomers and attack them. This caused their actions to become increasingly strange, and the obstructions become more and more horrific. Living explosions, blood & gore, violence. The more we resisted the newcomers, the more awful and incomprehensible the entire situation became.

But, noticed a few, the situation was not universal. There were some interactions with the newcomers where their actions ran harmoniously with ours, and the obstructions were curiously absent.

Through careful analysis and experimentation, some principles and practices were discovered that showed us how to live harmoniously with the newcomers. Some even discovered that not only could they survive, it was possible to flourish and even soar.

With peace returning, we were able to spend time closely studying the new creatures and their curiously symbiotic relationship to ourselves.

Time and attention revealed that the others where our own actions, manifested as a physical entity. Their actions were the new version of ourselves following our actions, and the obstructions were the consequences of our actions.

July 29th, 2014 8:44am


Never start a project involving legacy code that has already been estimated & scoped by someone other than myself.

October 21st, 2015 10:56am


Our team recently began using PhraseApp for translations/localizations. It's a great service. But, we hit a problem:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

We tried the usual things:

brew uninstall openssl
brew install openssl
brew link openssl --force
rvm osx-ssl-certs update all

and imploding rvm and the like, all to no avail. Eventually, the solution was found using the following:

ssl-tool: Misc. tools to help with debugging WTF is going on with SSL connections and Ruby

This showed that there was an expired CA cert from GlobalSign on the dev machine.

It was then fixed with this:

OpenSSL and dealing with expired Root CA certs

I hope this helps anyone else who encounters this.

August 25th, 2015 10:27am #ruby #ssl #certificates #expired #homebrew


/boot/config.txt for Raspberry Pi to use all of a Kogan 1080p screen:


December 2nd, 2015 4:19pm


Enter your email to subscribe to updates.