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 / run.sh
Created February 8, 2017 19:23 — forked from anonymous/run.sh
Go: Reflecting valid values
$ go run valid.go
main.Thing{Age:sql.NullInt64{Int64:99, Valid:true}, Lender:(*sql.NullString)(nil), Blue:sql.NullBool{Bool:false, Valid:false}}:
- Age: 99
main.Thing{Age:sql.NullInt64{Int64:1, Valid:true}, Lender:(*sql.NullString)(0xc82008a000), Blue:sql.NullBool{Bool:false, Valid:false}}:
- Age: 1
&main.Thing{Age:sql.NullInt64{Int64:0, Valid:false}, Lender:(*sql.NullString)(0xc82008a020), Blue:sql.NullBool{Bool:false, Valid:false}}:
- Lender: "Friend"
&main.Thing{Age:sql.NullInt64{Int64:0, Valid:false}, Lender:(*sql.NullString)(nil), Blue:sql.NullBool{Bool:true, Valid:true}}:
- Blue: true
&main.Thing{Age:sql.NullInt64{Int64:44, Valid:true}, Lender:(*sql.NullString)(0xc82008a080), Blue:sql.NullBool{Bool:false, Valid:true}}:
function go-local-package() {
go list ./... | head -1 | xargs dirname
}
function go-diff() {
ROOT_PKG=$(go-local-package)
go list -f '{{.Name}} {{.ImportPath}} {{.Deps}}' $(go list $ROOT_PKG/...) | \
grep ^main | \
grep -w -f <(
git diff --dirstat ${2:-master}...${1:-HEAD} | \
@icio
icio / _readme.md
Created November 29, 2013 14:11
Dominos Slack notifier

Dominos → Slack Notifier

Paste this snippet into your web browser's console when viewing the Pizza Tracker page offered after submitting a Dominos order. When the state changes it'll post the order state to your specified Slack Incoming Webhook. Use the URL at the top of your existing integration to paste into the prompt you receive when running the snippet. It should be in the form of: "https://TEAM.slack.com/services/hooks/incoming-webhook?token=TOKEN".

You'll need to leave your browser window open until it's done, of course. Tested in Chrome in the UK. Not tested with collections.

@icio
icio / keybase.md
Created May 7, 2016 15:17
keybase.md

Keybase proof

I hereby claim:

  • I am icio on github.
  • I am icio (https://keybase.io/icio) on keybase.
  • I have a public key ASBBQCsu980HaJfo_B6E2_2q5i6miC4B7Ho28ym7fYx7kQo

To claim this, I am signing this object:

@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 / 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 / inputrc
Created January 22, 2014 13:47
Ubuntu input rc
# /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 January 3, 2016 12:59
Azure IP ranges from http://msdn.microsoft.com/en-us/library/windowsazure/dn175718.aspx converted into a format for Cloudflare's threat control.
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 January 10, 2014 14:23
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.
/**
* 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";