Skip to content

Instantly share code, notes, and snippets.

@bradwright
bradwright / has-attribute.js
Created July 29, 2011 09:29
Cross browser hasAttribute
function hasAttribute(node,attr) {
return node.hasAttribute ? node.hasAttribute(attr) : !!node.getAttribute(attr);
}
@bradwright
bradwright / websockets-server.js
Created June 11, 2011 23:29
Pure Node.js WebSockets server
/*
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <[email protected]>
*/
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');
@bradwright
bradwright / diskspace.cron
Created March 17, 2011 09:06
Checks disk space is below a certain % threshold, otherwise sends an email using sendmail
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
sendmail [email protected] << EOF
Subject: [alert] Disk space alert
To: ME <[email protected]>
Your root partition remaining free space is critically low. Used: $CURRENT%
@bradwright
bradwright / .localscreenrc
Created February 28, 2011 15:37
Local screen RC that runs an alias called "scd" after creating screens. Normally screen fails at this.
# local screenrc
screen -t bash 0
screen -t "paver run" 1
screen -t "python shell" 2
screen -t syslog 3 tail -F /var/log/syslog
screen -t mailqueue 4
# run some bash aliases
select 1
stuff "scd\012"
@bradwright
bradwright / linode-secure-ubuntu-stackscript.sh
Created February 13, 2011 19:56
StackScript to make a more secure Ubuntu server install out of the box
#!/bin/bash
# Setup script designed to get a Ubuntu 10.4 LTS server
# up and running with secure defaults.
# Documentation for StackScripts
# is pretty sparse: see http://www.linode.com/stackscripts/
# User-inputted values for new Linode
# <UDF name="user_hostname" Label="Hostname for new Linode" />
@bradwright
bradwright / colours.py
Created November 18, 2010 16:06
Usage: python colours.py [colour]
#!/usr/bin/env python
import sys
def count_colours(colours):
colour_index = {}
for i, colour in enumerate(colours):
if colour in colour_index:
colour_index[colour].append(i)
else:
@bradwright
bradwright / gist:595081
Created September 24, 2010 08:57 — forked from andyhd/gist:595058
# a heavy int is one where the average of the digits is greater than 7
# eg: 8678 is heavy because (8 + 6 + 7 + 8) / 4 = 7.25
# 8677 is not heavy because ( 8 + 6 + 7 + 7) / 4 = 7
def is_heavy(my_number, heaviness=7):
# cast @my_number to a string so we can iterate over it, then create a list of
# numbers greater than @heaviness. if this list length is greater to or equal than half
# the length of the original list, it's heavy
return len([i for i in str(my_number) if int(i) > heaviness]) >= (len(str(my_number)) / 2)
all_possible_plays = Play.objects.filter(preview_only=False, play_start__gte=start_date,
play_start__lt=end_date, users__is_staff=False)
for play in all_possible_plays:
if play_history.has_key(play.song.pk):
#increment tallies
play_history[play.song.pk]['plays'] += 1
if play.credit_taken:
play_history[play.song.pk]['credit_plays'] += 1
import re
pattern = re.compile('^.*?((?<!\.[a-z0-9]{8})png|jpg|gif|swf|ico|flv|zip)$')
# I want the first two to match, but not the second two
file_list = [
'main.ie6.zip',
'main.zip',
'main.cb1c4aa1.zip',
'main.cb1c4aa1.cb1c4aa1.zip'
]

Smarkets (London, UK)

Job description

Smarkets, a London-based betting exchange startup, is looking for an experienced front end web developer for a full time position with an immediate start.

Our front end application is a collection of Django apps built on an exclusively Python API client (to a RESTful Erlang API), and we're looking for someone to build out user-facing features.