Skip to content

Instantly share code, notes, and snippets.

Working from home

Barnaby Gray barnybug

Working from home
View GitHub Profile
barnybug /
Created Jul 17, 2018
kubernetes tips

List pods ordered by node:

kubectl get po -o=wide --sort-by=.spec.nodeName

List nodes by instance type / zone:

kubectl get no
barnybug / docker-compose.yml
Created Nov 21, 2017
Docker compose for a Docker-in-docker gitlab runners setup
View docker-compose.yml
# Docker-in-Docker Gitlab runners setup taken from:
restart: always
privileged: true
- /var/lib/docker
image: docker:17.09.0-ce-dind
- --storage-driver=overlay2
View gist:3c58c058c687c61c51107e6756f736a5
_index: "events_201701160824",
_type: "event",
_id: "AV6VlZ-AHWGhPQNyr0dK",
_score: 6.8922844,
_source: {
event: "portal.impressions",
sid: "dc7e7cec-800a-4454-b89e-2d42dfe0097a",
pid: "a03f0281-c9e3-4ba2-b5d0-92af0554af54",
total_count: 1,
View main.nim
import macros
import strutils
proc compile(input: string, setup: string): NimNode {.compiletime.} =
var caseBody = newNimNode(nnkCaseStmt)
caseBody.add parseExpr("pc")
var pc = 0
template addCase(text): typed =
var branch = newNimNode(nnkOfBranch)
View gist:ad0f224d015f62111e50cfb0bef6aeb1
~ % mosquitto_sub -h -t 'cheerlightsRGB'
~ % mosquitto_sub -h -t 'cheerlights'
View gist:b37b661384d41c98c843aa7111ec9c45
~ % mosquitto_sub -h -t 'cheerlightsRGB'
^C⏎ ~ % mosquitto_sub -h -t 'cheerlights'
def get_code(tree, feature_names, class_names):
left = tree.tree_.children_left
right = tree.tree_.children_right
threshold = tree.tree_.threshold
features = [feature_names[i] for i in tree.tree_.feature]
value = tree.tree_.value
def recurse(left, right, threshold, features, node, indent):
if threshold[node] != -2:
print "%sif %s <= %s:" % (indent, features[node], threshold[node])
% Prolog solution to:
left(X, Y, [X | [Y | _]]).
left(X, Y, [_ | List]) :- left(X, Y, List).
neighbour(X, Y, List) :- left(X, Y, List); left(Y, X, List).
% house(Person, Pattern, Pet, Drink, Transport)
solution(Answer) :- Z = [_, _, _, _, _],
% 1. Nicola lives in the tartan house.
View gist:cc7b717387474bea18ac
// Bug demonstrating Release crash in swift code (XCode 6.2 / swift 1.1, Release builds only)
import UIKit
import XCTest
func dictSetValue(value: AnyObject, forKey key: String, inout #dictionary: [String : AnyObject]) {
dictSetValue(value, forKeyPathComponents: key.componentsSeparatedByString("."), dictionary: &dictionary)
func dictSetValue(value: AnyObject, forKeyPathComponents components: [String], inout #dictionary: [String : AnyObject]) {
#!/usr/bin/env python
# Script to run dynamic dns for docker containers.
# DNS is served by dnsmasq running on the docker0 gateway ip, and dynamically
# updated at containers come and go.
# To use from docker, just provide the --dns option:
# docker run --dns <gateway> ...
# The gateway ip you need will be printed when this script is run.