Skip to content

Instantly share code, notes, and snippets.


Tom Anderson tomwhoiscontrary

View GitHub Profile
#! /usr/bin/env python
Conceptual complexity: the incidental complexity of the code is low,
because it directly realises the mathematical algorithm, whose intrinsic
complexity is, for the non-mathematical layman, about a cup of tea's
worth of scribbling on a notepad
Time complexity: you know, i have no idea; it's probably related to the
number of factors in the inputs, and the number of factors in common
tomwhoiscontrary /
Last active Aug 29, 2015
Script to interactively sort some options by repeated comparison
#! /usr/bin/env python
import sys
import itertools
def recording_in(d):
def recording(f):
def recording_f(*args):
result = f(*args)
d[args] = result
#! /usr/bin/env python
import sys
labels = sys.argv[1:]
rows = map(lambda strings: map(int, strings), map(str.split, map(str.rstrip, sys.stdin.readlines())))
def vote(row):
assert len(row) == len(labels)
tomwhoiscontrary / dollars.hs
Created Mar 27, 2014
London Code Dojo - 7 languages in 7 weeks: Haskell day 2 - code by Tom A and a bunch of other people
View dollars.hs
module Dollars where
import Test.HUnit
-- parsing dollars
parseDigit '0' = 0
parseDigit '1' = 1
tomwhoiscontrary /
Created Apr 23, 2014
Fails to compile under javac 1.6.0_26
package com.youdevise;
import com.youdevise.Firmament.Air.Earth;
public class Firmament {
public static class Air implements Serializable {
public static class Earth {}
tomwhoiscontrary / valediction.rst
Created Jun 19, 2014
What i learned my last job
View valediction.rst
  • That working with a group of smart and well-informed developers is really enjoyable, but not sufficient to reliably make high-quality software (i don't know why not).
  • How modern system administration is done, and a little about how it ought to be done.
  • That large-scale automated CI, with dozens and dozens of slaves testing every conceivable aspect of the software in a short space of time, is possible and awesome.
  • That if one day you don't feel like doing a proper job of something, or perhaps even finishing it at all, you can just tell everyone you're "focusing on delivering the business value", and it's fine.
  • That the financial industry really is run just as badly as you feared.
SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']}
def approximate_size(size, a_kilobyte_is_1024_bytes=True):
"""Convert a file size to human-readable form.
Keyword arguments:
size -- file size in bytes
a_kilobyte_is_1024_bytes -- if True (default), use multiples of 1024,
if False, use multiples of 1000
View spring.log
2015-01-15 18:28:09.984 ERROR 18560 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration.managementServerProperties
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(
View fix-eventsource-fields.diff
diff --git a/commands/execute.go b/commands/execute.go
index d1a30ca..9d51506 100644
--- a/commands/execute.go
+++ b/commands/execute.go
@@ -96,8 +96,8 @@ func Execute(c *cli.Context) {
signal.Notify(terminate, syscall.SIGINT, syscall.SIGTERM)
eventSource := &sse.EventSource{
- Client: atcRequester.httpClient,
- CreateRequest: func() *http.Request {
View bermuda_triangle.txt
± |master ✗| → fly --atcURL= execute -c deploy.yml
2015/02/02 17:57:41 bad response when creating pipe: &{301 Moved Permanently 301 HTTP/1.1 1 1 map[Content-Length:[0] Content-Type:[text/plain; charset=utf-8] Location:[/api/v1/pipes] Date:[Mon, 02 Feb 2015 17:57:40 GMT]] 0xc208036e80 0 [] false map[] 0xc2080352b0 <nil>}
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Content-Type: text/plain; charset=utf-8
Date: Mon, 02 Feb 2015 17:57:40 GMT
Location: /api/v1/pipes
You can’t perform that action at this time.