Skip to content

Instantly share code, notes, and snippets.

graingert /
Last active Dec 19, 2019


Twisted tests will generally look like:

@twisted_utils.reacts  # marks the test as needing a reactor
# marks the function as a coroutine, a poor immitation of a Python3 async/def
# coroutine
def test_foo(fixtures)
View Dockerfile
FROM ubuntu:xenial
COPY ./ /tmp/
RUN echo "deb xenial main" > /etc/apt/sources.list.d/deadsnakes.list \
&& apt-key add /tmp/ && rm /tmp/ \
&& apt-get update && apt-get install -y --no-install-recommends libgtk2.0 libwebkitgtk-3.0 \
build-essential python2.7-dev python3.7-dev python3.7-venv python-virtualenv \
libjpeg8 libtiff5 libsdl1.2debian libnotify4 freeglut3 libsm6 \
libgl1-mesa-glx libgstreamer-plugins-base0.10 libwebkit2gtk-4.0-37 git \
&& rm -rf /var/lib/apt/lists/*
graingert /
Last active Apr 10, 2019
import pathlib
import ast
def _packages(path):
return _include_parents(path.with_suffix('').parts)
def _include_parents(parts):
p = list(parts)
import json
with open('./foo.json') as df:
dump = json.load(df)
for f in dump:
fp = f['filePath']
rules = ', '.join(sorted(set(m['ruleId'] for m in f['messages'])))
if not rules:
graingert / repl.scala
Created Dec 20, 2017 — forked from fedesilva/repl.scala
Voldemort types in scala
View repl.scala
f@omoikane:~$ scala
Welcome to Scala version (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :load Workshop/mine/scala-misc/voldemort.scala
Loading Workshop/mine/scala-misc/voldemort.scala...
defined module Dungeon
scala> val nemesis = Dungeon curse "fedesilva"
View ajaxcall.js
map.on('click', function(event){
var x1_wgs;
var y1_wgs;
async function ajax(x,y){
const data = $.ajax({
View List.js
class List {
constructor() {
this.arr = undefined;
this.length = 0;
this.inLength = 0;
this.dirty = false;
this.prev = undefined;
push(v) {
graingert / Dockerfile
Created Jun 26, 2017 — forked from tabiodun/Dockerfile
Dockerfile for tabiodun/selenium-chrome-headless
View Dockerfile
FROM selenium/node-base:3.4.0-dysprosium
USER root
ARG CHROME_VERSION="google-chrome-beta"
RUN wget -q -O - | apt-key add - \
&& echo "deb stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -qqy \
&& apt-get -qqy install \
graingert / gist:bf23f6f4193679272307cc2c1ac1e763
Created May 15, 2017 — forked from colin-kiegel/gist:b35d278d6ed5251dfa85
regex replace multi-line + in multiple files
View gist:bf23f6f4193679272307cc2c1ac1e763
find . -name "$FILES" | xargs perl -0777 -pi -e '$REGEX'
# flag: -0777 tells perl to read the file as a whole
# replace '-pi' with '-pi.bak' to create backups
graingert / LICENSE
Last active Mar 30, 2017
The MIT License (MIT)
Copyright (c) 2016 Thomas Grainger.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
You can’t perform that action at this time.