Skip to content

Instantly share code, notes, and snippets.

@shanna
shanna / README.md
Last active August 29, 2015 14:19
BuildKite Systemd Target

BuildKite Systemd Target

Debian Jessie buildkite agent when networking is up.

/etc/systemd/system/buildkite-agent.service

@shanna
shanna / gist:6d2a6c91222ba4fa81a4
Created December 17, 2014 03:02
printf uint64_t binary.
// Has the advantage of not needing a temp buffer.
#define BINARY_8_FORMAT \
"%d%d%d%d%d%d%d%d"
#define BINARY_8_PARAMS(byte) \
(byte & 0x80 ? 1 : 0), \
(byte & 0x40 ? 1 : 0), \
(byte & 0x20 ? 1 : 0), \
(byte & 0x10 ? 1 : 0), \
(byte & 0x08 ? 1 : 0), \
@shanna
shanna / example.protocol
Last active December 22, 2015 09:38
DSL to generate a protocol definition tree.
package :foo do
enum :test, {foo: 1, bar: 2, end: 99}
struct :hsv do
float :h
float :s
float :v
end
struct :example do
@shanna
shanna / router.js
Created February 20, 2013 00:59
A javascript router.
/*
Router.
Unlike larger projects (crossroads-min.js ~6.8kb, davis-min.js ~10kb, ...)
this router <1kb is intended to do one thing well; route. No events,
listeners, loggers, history or any other bullshit just a way to execute
callbacks by path.
@example
// document.location.pathname #=> /posts/media/2
@shanna
shanna / bench.sh
Last active December 12, 2015 05:38
Evil or awesome use of tags in golang for debugging?
#!/bin/sh
go test -test.bench . 2> /dev/null
go test -tags debug -test.bench . 2> /dev/null
@shanna
shanna / flags.c
Last active December 12, 2015 02:38
Simple C flag parser using uthash. http://troydhanson.github.com/uthash/
#include "flags.h"
#define isopt(text) strncmp(text, "--", 2) == 0
#define isneg(text) strncmp(text, "--no-", 4) == 0
flags_t *flags_parse(int argc, char *argv[]) {
int n;
char *option, *value;
flags_t *flags = NULL, *flag;
// code for http://gowithconfidence.tumblr.com/post/31797884887/limit-buffers
package main
import (
"bytes"
"errors"
"fmt"
"io"
"sync"
@shanna
shanna / tms.c
Created December 3, 2012 05:42
libmosquitto mosquitto_topic_matches_sub
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <mosquitto.h>
int main (int argc, char *argv[])
{
bool matches = false;
mosquitto_topic_matches_sub(argv[1], argv[2], &matches);
printf("matches: %d\n", matches);
@shanna
shanna / persona.go
Created October 8, 2012 13:00
Persona Verification in Go
package persona
import (
"encoding/json"
"io/ioutil"
"net/http"
"net/url"
)
type Auth struct {
@shanna
shanna / Makefile
Created July 5, 2012 23:59
Watch and compile JS and CSS.
templates:
cd web/templates && haml-coffee -i . -n this.nd.templates -o ../js/nd-templates.js
css:
cd web/css && recess nd.less --compile > ../../public/nd.css
app:
cd web/app && coffee -cj ../js/nd.js nd.coffee
js: