Skip to content

Instantly share code, notes, and snippets.


Sam Clements borntyping

View GitHub Profile
class Chain:
def __init__(self):
self.functions = []
def and_then(self, func):
return self
def __call__(self, value):
result = value
import path
import json
import attr
import cattr
class Config:
foo: int = attr.ib()
bar: str = attr.ib()
def main(ctx: click.Context, dev: bool, next: bool):
config_file = 'odyssey.json'
log_file = 'odyssey.log'
if next:
config_file = 'odyssey-next.json'
log_file = 'odyssey-next.log'
if not dev:
config_file = os.path.join('/etc/gb/marrs/', config_file)
View time.rb
class TimePeriod
attr_accessor :seconds
def hours
seconds / 3600
def hours=(value)
seconds = value * 3600
View example.rb
module ExampleModule
def hello
puts 'hello world'
class ExampleClass
include ExampleModule
View Makefile
# pdflatex options:
# -shell-escape is used by the minted package to call pygments
# -interaction=nonstopmode stops pdflatex waiting for user input on errors
pdflatex = pdflatex -shell-escape -interaction=nonstopmode report.tex
pdflatex_warn = $(pdflatex) | grep Warning | grep -v 'float' | sed "s/^LaTeX / /"
pdflatex_error = $(pdflatex) | grep -e "^!" | sed "s/^! / Error: /"
pdflatex_quiet = $(pdflatex) >/dev/null
# Other tools
texcount = texcount -merge -template="{1}" report.tex
View gist:3336e1b5a7aeaa2f117e
//! Wrapper around Rc<Box<T>>
use std::ops::{Deref,DerefMut};
use std::rc::Rc;
struct Reference<T: ?Sized>(Rc<Box<T>>);
impl<T : ?Sized> Reference<T> {
borntyping / Cargo.lock
Created Mar 17, 2015
rust-protobuf failing to encode messages with numbers set
View Cargo.lock
name = "rust-protobuf-repro"
version = "0.0.1"
dependencies = [
"protobuf 0.0.9 (git+",
name = "protobuf"
version = "0.0.9"
View gist:a689b4b0256802a7342d
RUN apt-get install -y nodejs npm
---> Running in f389969cc6f7
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
binutils build-essential cpp cpp-4.8 dpkg-dev fakeroot g++ g++-4.8 gcc
gcc-4.8 gyp javascript-common libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan0 libatomic1
libc-ares-dev libc-ares2 libc-dev-bin libc6 libc6-dev libcloog-isl4
use std::collections::HashMap;
use std::fmt::Debug;
use std::rc::Rc;
// Resources -------------------------------------------------------------------
trait Resource : Debug { }
trait Process : Resource + Debug { }
trait Service : Resource + Debug { }
You can’t perform that action at this time.