Skip to content

Instantly share code, notes, and snippets.

@danielchatfield
danielchatfield / snippets.tex
Last active November 14, 2015 20:06
LaTeX Snippets
% Allow utf8 in source
\usepackage[utf8]{inputenc}
% Allow abbreviations for SI units
\usepackage[load=abbr]{siunitx}
% Change range format from "1.2GHz to 1.3GHz" to "1.2-1.3GHz"
\sisetup{range-phrase=--,range-units=single}
@danielchatfield
danielchatfield / router.txt
Created September 29, 2015 11:20
Info from router firmware
Default password: C69D9E5C12934C98
@danielchatfield
danielchatfield / download.sh
Last active August 29, 2015 14:16
Download pastpapers
PPROOT="http://www.cl.cam.ac.uk/teaching/exams/pastpapers/"
for year in $(seq 2000 2009 $end); do \
for paper in $(seq 3 6 $end); do \
download ${PPROOT}y${year}PAPER${paper}.pdf; \
for question in $(seq 12); do \
download ${PPROOT}y${year}p${paper}q${question}.pdf; \
done; \
done; \
done;
@danielchatfield
danielchatfield / umm_no.md
Last active August 29, 2015 14:06
Apple streaming issue

This article by Dan Rayburn, self proclaimed "voice for the streaming & online video industry" has been making the rounds on twitter and briefly hacker news (until it was appropriately downvoted for being nonsensical rubbish). The article is so void of anything which remotely resembles reasoned argument that one could easily mistake it for satire.

Unlike the last live stream Apple did, this time around Apple decided to add some JSON (JavaScript Object Notation) code to the apple.com page which added an interactive element on the bottom showing tweets about the event.

Firstly JSON isn't code, it was JS code that pulled in JSON.

As a result, this was causing the page to make refresh calls every few milliseconds.

You would have to be pretty forgiving with your definition of "few" here.

@danielchatfield
danielchatfield / test.txt
Last active August 29, 2015 14:05
github email testcase
Interesting bug, stripe needs to be able to distinguish between setting an
attribute to None which exists in the saved entity and setting an attribute
to None which hasn't been saved yet.
A hack to fix this would be to manually remove "coupon" from
customer._unsaved_values.
It looks like the __setattr__ method could be modified to check whether the
key is in _retrieve_params and if it isn't and the value is None then
remove the key from _unsaved_values. I'll put together a pull request when
@danielchatfield
danielchatfield / decorator.py
Last active August 29, 2015 14:04
Better decorator
from myapp import app
from werkzeug import BaseResponse
from flask import current_app
def render_html(template, **defaults):
def wrapped(result):
variables = defaults.copy()
variables.update(result)
return render_template(template, **variables)
return wrapped

Keybase proof

I hereby claim:

  • I am danielchatfield on github.
  • I am danielchatfield (https://keybase.io/danielchatfield) on keybase.
  • I have a public key whose fingerprint is 463B 75C9 5496 C8D0 0B2C 20D5 D486 A05D D8E3 7789

To claim this, I am signing this object: