Skip to content

Instantly share code, notes, and snippets.

View mstade's full-sized avatar

Marcus Stade mstade

View GitHub Profile
@marick
marick / about_those_lava_lamps.md
Last active June 22, 2022 21:08
About Those Lava Lamps

Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.

By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.

@mbostock
mbostock / .block
Last active February 9, 2016 01:57
Solar Oscillator
license: gpl-3.0
@brianarn
brianarn / maths.js
Last active July 6, 2020 22:08
Module to wrap `console.group` around all methods
// A simple object with some methods,
// which throw errors when bad arguments are passed.
var maths = {
square : function (value) {
// Validity checking
if (arguments.length !== 1) {
throw new Error('square: Requires one and only one argument');
}
if (typeof value !== 'number') {
throw new Error('square: Requires numeric argument');
@ftrain
ftrain / rhymes.clj
Last active July 14, 2023 22:20
Annotated rhyming dictionary
;; This is at: https://gist.github.com/8655399
;; So we want a rhyming dictionary in Clojure. Jack Rusher put up
;; this code here:
;;
;; https://gist.github.com/jackrusher/8640437
;;
;; I'm going to study this code and learn as I go.
;;
;; First I put it in a namespace.

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

#!/bin/sh
#
# Usage: git semver-tags [-p|--pre]
#
# Lists semver tags in the repository in order from newest to oldest.
#
# Useful for e.g. programmatically finding the latest release tag:
# `git semver-tags | head -n 1`.
#
# Tag names must be valid according to the SemVer 1.0.0 specification
@shesek
shesek / gist:3929926
Created October 22, 2012 06:01
Higher order functions for nodejs-style callbacks error handling

I've used promises for quite some time, but ended up going back to nodejs-style callbacks and creating a bunch of higher-order functions that makes handling that easier and reduce the boilerplate code. The two most useful ones, that really made it much easier, deal with error handling/bubbling: (CoffeeScript)

iferr = (errfn, succfn) -> (e, a...) -> if e? then errfn e else succfn a...
throwerr = iferr.bind null, (e) -> throw e


# To let an error bubble up, `iferr` decorates the success function and the error function, and decide which one should handle the response
# This replaces `if (err) return fn err` that you see all over the place