Skip to content

Instantly share code, notes, and snippets.

import urllib
from xml.dom import minidom
class TubeStatusProvider():
LINESTATUS_URL = 'http://cloud.tfl.gov.uk/TrackerNet/LineStatus'
def get_status(self):
statuses = []
<div class="section">
<div class="header">
<h2>{{ title }}</h2>
</div>
<table class="content">
<thead>
<tr>
<th>Line</th>
<th>Status</th>
</tr>
@cnorthwood
cnorthwood / stylechanges.diff
Created June 15, 2011 16:04
CSS changes between Molly 1.1.2 and i18n branch
diff --git a/molly/apps/places/static/places/css/smart.css b/molly/apps/places/static/places/css/smart.css
new file mode 100644
index 0000000..95a0846
--- /dev/null
+++ b/molly/apps/places/static/places/css/smart.css
@@ -0,0 +1,27 @@
+/* RTI */
+table.real-time-information {
+ width: 100%;
+ background: #121C28;
>>> class IdentifierList(list):
... def by_namespace(self):
... return None
...
>>> class Locality():
... @property
... def identifiers(self):
... return IdentifierList(self._identifiers)
... @identifiers.setter
... def identifiers(self, value):
@cnorthwood
cnorthwood / gist:5564150
Last active December 17, 2015 06:19
why does this not work?
<?php
class Base {
public static $value;
public static function get() {
return static::$value;
}
}
@cnorthwood
cnorthwood / vstp.py
Created January 13, 2015 21:56
Sample Network Rail Open Data python script
#!/usr/bin/env python
"""
Sample Python connect script. Requires stomp.py: pip install stomp.py
"""
import logging
from time import sleep
import stomp
nums = set(range(60, 70))
for i in range(1, 36):
for j in range(i, 36):
if sum(range(i, j)) in nums:
nums.remove(sum(range(i, j)))
if sum(range(j, 36)) in nums:
nums.remove(sum(range(j, 36)))
print nums
most_recent=`s3cmd ls $S3_BUCKET | cut -d/ -f4 | sort | tail -1`
base=`mktemp -d`
function restore_from_zip() {
type=$1
dest=$2
unzip $type.zip -d $type
rm -rf $dest
mv $type/ $dest/
chown -R go:go $dest/
@cnorthwood
cnorthwood / code.py
Created December 6, 2015 20:48
Advent of Code day 6
from collections import defaultdict
import re
INPUT = """turn on 887,9 through 959,629
turn on 454,398 through 844,448
turn off 539,243 through 559,965
turn off 370,819 through 676,868
turn off 145,40 through 370,997
turn off 301,3 through 808,453
turn on 351,678 through 951,908
@cnorthwood
cnorthwood / code.py
Created December 7, 2015 12:37
Advent of Code day 7 part 1
INPUT = """lf AND lq -> ls
iu RSHIFT 1 -> jn
bo OR bu -> bv
gj RSHIFT 1 -> hc
et RSHIFT 2 -> eu
bv AND bx -> by
is OR it -> iu
b OR n -> o
gf OR ge -> gg
NOT kt -> ku