Skip to content

Instantly share code, notes, and snippets.

View icio's full-sized avatar
💬
icio is typing...

Paul Scott icio

💬
icio is typing...
View GitHub Profile
@icio
icio / tfl.go
Last active April 16, 2016 14:49
TfL Journey History
// 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 / .bashrc
Last active January 31, 2020 16:54
dotfiles
#!/usr/bin/env bash
function run_scripts() {
for script in $1/*; do
# skip non-executable snippets
[ -x "$script" ] || continue
# execute $script in the context of the current shell
. $script
@icio
icio / jawa-pockets.md
Last active January 16, 2016 18:12
Jawa Pockets

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 January 6, 2016 14:20
Python enter_context
"""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 / array_benchmark.php
Last active August 29, 2015 14:21
Array merge benchmark
<?php
/*
$ php ~/test.php
Runs: 100,000
Benchmark Avg (s) Total (s)
---------- ---------- ----------
sum 0.000006 0.597605
merge 0.000007 0.713410
@icio
icio / input.twig
Last active August 29, 2015 14:15
Twig JavaScript Escaping
{% set text = 'back & for"th' %}
<script>
console.log({
"str0": "{{ text }}",
"str1": "{{ 'back & for"th' }}",
"num1": {{ 123 }},
"str2": "{{ 'back & for"th' | e('html') }}",
"num2": {{ 123 }},
@icio
icio / recurly-upgrade-2.1.2-2.3.1.patch
Created February 2, 2015 16:52
Recurly 2.1.2 → 2.3.1 Upgrade (./lib directory diff)
diff -r html/sites/all/libraries/recurly_v2/recurly/account.php vendor/recurly/recurly-client/lib/recurly/account.php
9c9,10
< function __construct($accountCode = null) {
---
> function __construct($accountCode = null, $client = null) {
> parent::__construct(null, $client);
11a13,15
> $this->address = new Recurly_Address();
> $this->balance_in_cents_invoiced = new Recurly_CurrencyList('balance_in_cents_invoiced');
> $this->balance_in_cents_uninvoiced = new Recurly_CurrencyList('balance_in_cents_uninvoiced');
@icio
icio / index.html
Created July 18, 2014 10:59
Fit polygon in box
<!--
https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
-->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Polytext</title>
<style type="text/css">
.polytext {
from itertools import groupby, count
def debug_iter(iter):
for x in iter:
print "=> %d" % x
yield x
def groupn(n, it):
@icio
icio / _redland-raptor-rasqal-osx.md
Last active August 29, 2015 14:03
Building Redland's Raptor RDF Syntax Library and Rasqal RDF Query Library on OSX
  1. Ensure that you have the relevant build tools at your disposal. build-essential ought to cover it.
  2. Download and run install.sh.
  3. Once the script has complete you'll need to sudo make install the packages that you're interested in (or run them locally) -- that's your call. If you're only after roqet then cd rasqal* && sudo make install