Skip to content

Instantly share code, notes, and snippets.

🎀
they/them

Sam Clements borntyping

View GitHub Profile
View chain.py
class Chain:
def __init__(self):
self.functions = []
def and_then(self, func):
self.functions.append(func)
return self
def __call__(self, value):
result = value
View config.py
import path
import json
import attr
import cattr
@attr.s()
class Config:
foo: int = attr.ib()
bar: str = attr.ib()
View cli.py
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
end
def hours=(value)
seconds = value * 3600
hours
View example.rb
module ExampleModule
def hello
puts 'hello world'
end
end
class ExampleClass
include ExampleModule
end
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>>
#![allow(dead_code)]
use std::ops::{Deref,DerefMut};
use std::rc::Rc;
struct Reference<T: ?Sized>(Rc<Box<T>>);
impl<T : ?Sized> Reference<T> {
@borntyping
borntyping / Cargo.lock
Created Mar 17, 2015
rust-protobuf failing to encode messages with numbers set
View Cargo.lock
[root]
name = "rust-protobuf-repro"
version = "0.0.1"
dependencies = [
"protobuf 0.0.9 (git+https://github.com/stepancheg/rust-protobuf.git)",
]
[[package]]
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
View main.rs
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.