Skip to content

Instantly share code, notes, and snippets.

Avatar
💬
icio is typing...

Paul Scott icio

💬
icio is typing...
View GitHub Profile
@icio
icio / tfl.go
Last active Apr 16, 2016
TfL Journey History
View tfl.go
// I take the tube in this morning to start collecting from data.
Account{
SpendingToday:240,
PendingPayments:[]main.Payment{
main.Payment{Origin:"Bethnal Green LU", Destination:"Liverpool Street LU", Cost:240}
}
}
// Later, I get on at Liverpool street, and when checking immediately after
// exiting Bank. Tfl have gotten this journey WRONG. Due to the absence of a
@icio
icio / jawa-pockets.md
Last active Jan 16, 2016
Jawa Pockets
View jawa-pockets.md

As you cruise along the vast expanses of Tatooine desert, your X-34 landspeeder begins to splutter and stutter, before drifting slowly to a halt. A brief scan of the horizon reveals few features you can aim for in search of rescue.

Miraculously, a troop of Jawas appear out of nowhere -- presumably masked by the heat waves engulfing all who dare make this journey. The Jawas, being the scavengers they are, can be identified by the clattering of their many belongings. You strike up a conversation with one of the shorter ones, who is willing to trade some supplies you can use to fix your vehicle in exchange for some help with their counting.

Each Jawa's cloak contains many pockets. Many of those pockets (which aren't nearly as wet as an Otter's) contain pockets themselves, which themselves may contain pockets, and so-forth. The Jawas need your help to determine how many items they own altogether.

The pockets are represented as an array of the number of items within the pocket, and pockets which contain other p

@icio
icio / enter_context.py
Created Jan 6, 2016
Python enter_context
View enter_context.py
"""Imperative enter/exit control for python contextmanagers.
Where you'd prefer to use `with`:
with my_context(123) as f:
do_something()
but only have access to before and after hook-functions (as with Flask):
def before_hook():
@icio
icio / inputrc
Created Jan 22, 2014
Ubuntu input rc
View inputrc
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information.
# Be 8 bit clean.
set input-meta on
set output-meta on
set completion-ignore-case on
set expand-tilde off
set mark-directories on
@icio
icio / azure.txt
Last active Jan 3, 2016
Azure IP ranges from http://msdn.microsoft.com/en-us/library/windowsazure/dn175718.aspx converted into a format for Cloudflare's threat control.
View azure.txt
65.52.128.0/20
65.52.144.0/20
213.199.128.0/21
213.199.136.0/22
168.63.4.0/22
168.63.8.0/22
168.63.20.0/22
168.63.24.0/21
137.116.204.0/22
168.63.12.0/22
@icio
icio / jira-issue-map-copy.js
Created Jan 10, 2014
Useful for when you have to move from one JIRA workflow to another but don't want to repeat the mapping for every fucking issue type.
View jira-issue-map-copy.js
/**
* Duplicate the mapping of Current Status to New Status from the first
* issue type to the subsequent issue types.
*/
var tbody = document.getElementById('workflow-mapping-table').querySelector('tbody');
var cell = tbody.appendChild(document.createElement('tr')).appendChild(document.createElement('td'));
cell.setAttribute("colspan", 3);
cell.style.textAlign = "right";
@icio
icio / tiles.py
Created Jan 5, 2014
Python command-line tile world for unix terminals
View tiles.py
#!/usr/bin/env python
def world():
world = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1, 0, 0, 0, 1],
@icio
icio / _readme.md
Last active Oct 13, 2015
Git review
View _readme.md

About

A utility for interfacing with reviewable git branches, as per GitHub issues. This is a wrapper around ghi.

Usage

git review [-h | -l [LABEL] | [-w] ISSUE | -s | -u]
   git review            List reviewable issues
   git review -h         Print usage instructions
   git review -l         Print the review label filtered by
@icio
icio / gist:3166670
Created Jul 23, 2012
Python for/else
View gist:3166670
# For and if
for module in self.modules.values():
ok = True
for f in filters:
if not f(module):
ok = False
break
if ok:
yield module
View delay.js
var _log_start = Date.now();
/**
* Helper for logging which prepends a time-offset
*/
function log()
{
console.log.apply(console, ["["+(Date.now()-_log_start)+"]"].concat(args(arguments)));
}