May 26, 2012
Posted in Software at 01:05 by graham
I attended Vancouver’s Polyglot Unconference, met some wonderful people, and got to present a session on Go (#golang). Here’s broadly what I said:
How do you decide what to learn?
You have an amount of cognitive resources to spend every day, what do you invest them in? You have a pile of books at home you’re going to get to, a growing list of “read later” bookmarks, and a list of tech you’ve been meaning to play with. Hopefully that list will be even longer by the end of today.
I’d like to propose a model for prioritising what you learn. And I’d like to share why I think Go is worth learning.
Picture a Venn diagram, three circles, with their intersection about where I’m standing:
Read the rest of this entry »
April 9, 2012
Posted in Society, Software at 01:14 by graham
There’s an excellent interview of Ward Cunningham at InfoQ (Nov 2011). He talks about agile, wiki’s (including smallest-federated-wiki), meta-programming, CoffeeScript, but mainly about living as a developer. He is fascinating and motivating. Here are some of my favorite quotes :
On pair programming / social coding
I don’t think any developer really wanted to work alone, but they got a reputation as being loners that was unjustified because they did so much in their head.
On agile’s pace of development
I feel that the formulation of most Agile methods are a little plodding, you are coming in, you do the same amount of work every day, but you don’t have days go by where nothing gets done. Like the tortoise and the hair, and the tortoise wins the race, because the tortoise doesn’t get stuck.
Read the rest of this entry »
March 15, 2012
Posted in Software at 18:59 by graham
Getting unit test code coverage in python, and in django, is easy thanks to coverage:
pip install coverage
coverage run manage.py test app1 app2 app3
coverage html --include="my_project/*"
www-browser htmlcov/index.html
A disadvantage of Django’s test runner is that by default it runs tests for all the packages in INSTALLED_APPS. Usually you only want to run tests for your apps, not for third-party libraries. Hence I prefer the test runner in django-jenkins:
pip install django-jenkins
or directly from git (at time of writing the –coverage-html is only in git):
pip install git+git://github.com/kmmbvnr/django-jenkins.git
Edit settings.py to add these lines, changing “my_project” in the last line to your project’s top level package name:
INSTALLED_APPS += ('django_jenkins',)
JENKINS_TASKS = ('django_jenkins.tasks.django_tests',)
PROJECT_APPS = [appname for appname in INSTALLED_APPS if appname.startswith('my_project')]
Now run jtest with coverage, and it will always include all your apps, and only your apps:
manage.py jtest --coverage-html-report=htmlcov
Older versions of django_jenkins don’t have --coverage-html, so use this:
coverage run manage.py jtest
coverage html --include="my_project/*"
www-browser htmlcov/index.html
As the name implies, django-jenkins is also a great choice if you’re using continuous integration server Jenkins.
Updated to include –coverage-html. Thanks kmmbvnr!
Note: I’ve had trouble running debugger pdb / pudb in a unit test started from jtest. Using just ‘test’ works fine.
March 13, 2012
Posted in Software at 06:00 by graham
On paternity leave for my second child, I found myself writing an in-memory hashmap (a poor-man’s memcached), in Go, Python and C. I was wondering how hard it would be to replace memcached if we wanted to do something unusual with our key-value store. I also wanted to compare my knowledge of the languages, and, well, I get bored easily!
The code is on github as Key-Value-Polyglot.
Each version implements enough of the get and set commands from the memcached protocol that we can test them with a memcached client.
The wonderful Internet
Thanks to a great discussion on Hacker News, in the comments here, and on reddit, I have heavily updated this post. You’re reading the new improved version.
Having the Internet review your code is humbling. It is also an amazing way to learn. The code, and my knowledge, have improved tremendously thanks to the feedback.
Read the rest of this entry »
February 29, 2012
Posted in Software at 03:56 by graham
I’ve been using the Go programming language for over four months in my spare time, mainly to write an IRC client (hatcog) – here is my trip report.
Go sits somewhere between C and Python. It has the static type checking and bit-twiddling powers of C (and pointers!), yet much of the speed of development and conciseness of Python (e.g. string split and join). Bruce Eckel called it a language designed to create servers, and I agree wholeheartedly.
Read the rest of this entry »
February 6, 2012
Posted in Society, Software at 01:37 by graham
A year here and he still dreamed of cyberspace, hope fading nightly. All the speed he took, all the turns he’d taken and the corners he’d cut in Night City, and still he’d see the matrix in his sleep, bright lattices of logic unfolding across that colorless void… The Sprawl was a long strange way home over the Pacific now, and he was no console man, no cyberspace cowboy. Just another hustler, trying to make it through.
But the dreams came on in the Japanese night like livewire voodoo, and he’d cry for it, cry in his sleep, and wake alone in the dark, curled in his capsule in some coffin hotel, his hands clawed into the bedslab, temperfoam bunched between his fingers, trying to reach the console that wasn’t there.
From Neuromancer, p4-5
January 3, 2012
Posted in Software at 18:08 by graham
Is my terminal connected to the console, or to a pipe?
import (
"exp/terminal"
"syscall"
)
if ! terminal.IsTerminal(syscall.Stdin) {
// read what was piped in
}
For example:
$ ./myprog # is a terminal
$ echo "boo" | ./myprog # not a terminal
Updated May 2012 to use the exp/terminal package.
December 22, 2011
Posted in Software at 23:32 by graham
My current project has a realtime part, using socket.io on nodejs, and a web part using django on nginx / gunicorn. Here’s a setup to put them both on the same port, and make them both go over SSL. I’m assuming you’re on Ubuntu.
Disclaimer: I got this working last night, so no promises. You’ll certainly want to tweak haproxy’s config for performance. I also only tested it with socket.io’s web socket transport.
Overview

- stunnel decrypts the ssl, so everything after that doesn’t know about it. It decrypts both web traffic (HTTPS to HTTP), and web socket traffic (WSS to WS).
- haproxy sends web socket traffic to node and web traffic to nginx.
- node runs socket.io, handling the web socket traffic.
- nginx serves static content.
- gunicorn runs python / django, and there’s a database out back somewhere, but that’s not relevant here.
Currently nginx doesn’t Read the rest of this entry »
November 16, 2011
Posted in Software at 02:17 by graham
There are lots of easy ways to improve the output of your command line scripts, without going full curses, such as single-line output, using bold text and colors, and even measuring the screen width and height.
The examples are in Python, with a summary example in Go (golang) at the end.
Single line with \r (carriage return)
Instead of printing a \n (which most ‘print’ methods do by default), print a \r. That sends the cursor back to the beginning of the current line (carriage return), without dropping down to a new line (line feed).
import time, sys
total = 10
for i in range(total):
sys.stdout.write('%d / %d\r' % (i, total))
sys.stdout.flush()
time.sleep(0.5)
print('Done ')
Read the rest of this entry »
November 3, 2011
Posted in Society, Software at 01:05 by graham
We’ve know for over 35 years that “adding manpower to a late software project makes it later”. Amazon has it’s two-pizza team heuristic: “If a project team can eat more than two pizzas, it’s too large”. The excellent Code Complete has a detailed explanation of how communication costs increase with team size. Yet we still need reminding.
Dhanji R. Prasanna has an excellent retrospective on his time on the Google Wave team. He sums up the problem with big teams very well:
And this is the essential broader point–as a programmer you must have a series of wins, every single day. It is the Deus Ex Machina of hacker success. It is what makes you eager for the next feature, and the next after that. And a large team is poison to small wins. The nature of large teams is such that even when you do have wins, they come after long, tiresome and disproportionately many hurdles. And this takes all the wind out of them.
For me, that’s really the crux of it. As a programmer, it kills you to not get stuff done. Large teams necessarily involve more communication, more complexity, and less getting stuff done. Large teams are a programmers equivalent of retirement.
« Previous Page — « Previous entries « Previous Page · Next Page » Next entries » — Next Page »