Wishful Coding

Didn't you ever wish your
computer understood you?

Say thanks to the man who makes your computer run

Today I was browsing HackerNews and reading up on the latest cool projects including at least 3 buzzword technologies, when I suddenly realized how strange it was to go "ooh" and "aah" for weekend projects written in fancy high-level languages while we are ignorant to the people who get their hand dirty to make it possible in the first place.

That is when I decided to find the authors of my sound card driver and thank them for their amazing work. I run Ubuntu now and then on my iMac, but the sound never worked for me, until recent versions of Ubuntu shipped the correct ALSA driver.

I encourage you to do the same.

  1. Go to a technology you use to write awesome applications or the solution to a problem you had.
  2. Look for the dependencies, and continue to drill down until you find a project that makes you blink your eyes ands say "wow, I didn't know this was involved."
  3. Thank the author. Really, I'm serious!

I had to find out which sound card I have, what the driver for that was, and finally who the authors are. It turns out It's the Intel HDA driver in the alsa-driver package. The source file contained their email addresses.

  • Did you know Node.js uses V8, which uses Scons, which uses Python, which uses readline, which uses ncurses, which are all compiled using GCC or LLVM?
  • Did you know you can use your package manager to see the dependencies of a project?
  • Did you realize your package manager installs hundreds of dependencies and dependencies of dependencies to run something like Python? 
  • Consider who is more awesome, the guy who writes a Twitter app in Node, the guy who made Node, or the guy who made Node possible.

Twitter OAuth for Open Source clients

After reading these two articles about how to compromise Twitter tokens from a client and about how Twitter is abusing OAuth secrets and screwing OS clients by blocking their tokens, I came up with the following plan.

key = "your key"
secret = "your secret"

try
    request = sign(twitter.com/verify_credentials, key, secret)
    request.post()
except 401
    key = "BigFish key"
    secret = "BigFish secret"

I really love Twitter and the Twitter API, but it is obvious by now that Twitter does not care about small OSS projects.

I propose small Open Source Twitter clients to use tokens from the big fish as a fallback for their own tokens. This will allow small clients to continue to work after their tokens are blocked(albeit under the big fish name), unless Twitter blocks their own clients as well or faces the fact that their approach doesn't work.

A more politically correct option would be to write an OAuth Echo service that stores your tokens in a secure place, and accepts request without a secret. Take your pick.

5 minutes Lisp in Python

I love both Python and Clojure, so after I read this gist about a Lisp in Ruby, I decided to craft my own in Python.

The idea is basically to abuse a few Python functions, namely Generators, Decorators and grouping to have a syntax that looks like Lisp with yield at the start of every statement.

It's all still Python, so you can mix and mach however you like, I sneaked a List Comprehension in the example, which fits the Lisp syntax quite well.

At the moment of writing, the Gist below is also #3 on HackerNews.

# 5 minutes Lisp in Python
# Pepijn de Vos <http://pepijndevos.nl>
#
# Inspired by 30 minutes Lisp in Ruby
# http://gist.github.com/562017
# 
# This Lisp does not read or parse anything at all.
# A generator and a Decorator are abused to run sexps.
#
# Usage:
# 
# Define a function decorated with @lisp and start every sexp with yield.
#
# The function names should be strings.
#
# Result is stored in fn name.
#
# Example below:
#

def lisp(fn):
    code = fn()
    val = code.next()
    while True:
        try:
            try:
                newval = getattr(__builtins__, val[0])(*val[1:])
            except AttributeError:
                newval = getattr(val[1], val[0])(*val[2:])

            val = code.send(newval)
        except StopIteration:
            return getattr(val[1], val[0])(*val[2:])

@lisp
def example():
  (yield 'join',
    ", #",
    (yield '__mul__',
      [(yield 'str', i) for i in
        (yield 'range', (yield '__add__', 5, 5))],
      2))

print example