Skip to content

Instantly share code, notes, and snippets.

@tj
tj / output
Last active October 18, 2018 04:12
#!/bin/sh
eval `go build -work -a 2>&1` && find $WORK -type f -name "*.a" | xargs -I{} du -hxs "{}" | gsort -rh | sed -e s:${WORK}/::g
@rmg
rmg / README.md
Last active July 26, 2023 19:34
Dump current directory and all contents to a git branch

git-snapshot

Out of band syncing to a local git branch.

This started as an experiment to see how commits could be created without modifying the working directory, the index, or the state of HEAD. The end result is like a cross between rsync and git stash using a specified branch.

Benefits

@bajtos
bajtos / rfc.js
Created December 9, 2013 19:17
RFC: syntax sugar for mocha tests calling multiple async functions
// Original code
it('does something complex', function(done) {
async.waterfall(
[
function setupSchema(cb) {
db.setupSchema(/*...*/, cb);
},
function createTestUser(cb) {
db.createUser({ name: 'a user name' }, cb);
}
@rmg
rmg / lineage.rb
Last active December 19, 2015 12:18
Lineage: Tap into the latent enumerable powers of your class's directed graph!
require 'set'
def Lineage(enum_name = :lineage, parent_accessor = :parent)
Module.new do
define_method enum_name do |&block|
if block.nil?
enum_for(enum_name)
else
next_parent, visited = self, Set[self]
while next_parent = next_parent.send(parent_accessor)
@jhs
jhs / example.js
Created December 10, 2012 03:16
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
@Gen2ly
Gen2ly / md2wp
Created July 9, 2012 23:34
Convert Markdown to Wordpress blogging format
#!/bin/bash
# Convert Markdown to Wordpress blogging format
# Required program(s)
req_progs=(ascii2uni pandoc)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
@rmg
rmg / Makefile
Created February 24, 2010 22:10
A rope-like approach to building up a DOM and spitting it out as text in C
# A rope-like HTML/SGML/XML tree generator
# Initializers inside "for (...)" is technically only as of C99
CFLAGS = --std=c99
# If we can live with the trailing 0's in the function calls, go pedantic
ifdef PEDANTIC
CFLAGS += -pedantic -Werror -DPEDANTIC
endif