Skip to content

Instantly share code, notes, and snippets.

View cstorey's full-sized avatar

cstorey

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cstorey
cstorey / coverage.rs
Last active September 29, 2017 23:40
use std::ptr;
/*
Experiments in recovering coverage from the sanitizer runtime. Build with cargo, adding:
RUSTFLAGS="-C passes=sancov -C llvm-args=-sanitizer-coverage-level=3 -Z sanitizer=address -C opt-level=3 -C debug-assertions=on -C debuginfo=2"
*/
extern "C" {
pub fn __sanitizer_cov_init();
pub fn __sanitizer_cov_dump();
pub fn __sanitizer_dump_coverage(pcs: *const usize, len: usize);
pub fn __sanitizer_maybe_open_cov_file(name:
@cstorey
cstorey / triangle-query.dot
Last active January 7, 2017 22:30
Query plan for `Q(a, b, c) <- R(a, b), S(b, c), T(a, b)`
# From https://arxiv.org/abs/1210.0481
digraph G {
rankdir=LR;
subgraph cluster_relations {
R [group="R"];
S [group="S"];
T [group="T"];
label = "relations";
s!\$C\$!,!g;
s!\$SP\$!@!g;
s!\$BP\$!*!g;
s!\$RF\$!\&!g;
s!\$LT\$!<!g;
s!\$GT\$!>!g;
s!\$LP\$!(!g;
s!\$RP\$!)!g;
s!\$u20\$! !g;
s!\$u27\$!'!g;
@cstorey
cstorey / hkt-ptr.rs
Created August 12, 2016 10:55
Enough higher-kinded-ness to (trivially) abstract over pointer types in rust.
use std::ops::Deref;
use std::rc::Rc;
use std::sync::Arc;
trait Ptr<T> {
type PT : Deref<Target=T>;
fn build(val:T) -> Self::PT;
}
#[derive(Debug)]
@cstorey
cstorey / lamport.dot
Last active December 13, 2016 10:58
Graphviz lamport diagrams (borrowed from palvaro's molly)
digraph spacetime {
rankdir=TD
splines=line
// outputorder=nodesfirst
subgraph cluster_proc_nodes {
label="";
proc_a [label="Process a",group="a"];
proc_b [label="Process b",group="b"];
}
@cstorey
cstorey / gitgviz.py
Created November 23, 2014 22:00
A trivial script to visualise a git history as a graphviz diagram.
import os, sys
from pygit2 import Repository, GIT_SORT_TOPOLOGICAL, GIT_SORT_REVERSE
import pygit2
from graphviz import Digraph
repository_path = pygit2.discover_repository(os.getcwd())
repo = Repository(repository_path)
def nfmt(target):
return "N{0}".format(target.id)
@cstorey
cstorey / IMG.sh.txt
Last active August 29, 2015 14:03
Render an image in a 256 colour capable terminal.
Adapted for 256 color terminals from the 24-bit colour version at https://git.gnome.org/browse/vte/tree/perf/img.sh?h=vte-0-36 .
Original script (and this adaptation) licensed under GPLv2.
Octocat image used under presumed license from https://octodex.github.com/faq.html
PATH := ./foo:$(PATH)
export PATH
foo:
mkdir -vp $@
foo/bar: foo
printf "#!/bin/echo Hello\n" > [email protected] && chmod +x [email protected] && mv -v [email protected] $@
runit_okay: foo/bar