Instantly share code, notes, and snippets.

Michael F. Lamb datagrok

View GitHub Profile
datagrok /
Created Jul 29, 2014
The server I built July 2013

Ordered these around 2013/07. As expected you can get better/cheaper stuff today.

The Lian Li PCQ-25b was the main thing I wanted, it is a mini itx case with no stupid CD ROM bay that will hold like 8(?) drives. It was hard to find a mini itx motherboard at the time with lots of SATA ports on it. But easier now i'm sure.

I stuck a crappy old power supply in it that I had left over, so that's not included. If you spend extra and get a "gold" or "platinum" instead of "bronze" its efficiency is greater (which lowers the amount of power it will use, especially when the components draw less.)

The CPU i used back then was 32nm sandy bridge; they have 22nm ivy bridge now, which are more power-efficient i think.

datagrok /
Last active Aug 29, 2015
Update a directory upon `git push`
datagrok /
Last active Aug 29, 2015
PulseAudio tricks for remote work, teleconferencing, etc.

PulseAudio tricks

Record both mic and headphones

By default, if you're using Mumble, Teamspeak, etc., and you use a separate piece of software to record the meeting, you'll get audio for either yourself or your remotes, but not both.

This simple method causes microphone input to be fed into the sound output. So, this will only work when:

  1. you are using headphones and
  2. you don't mind hearing your own voice in your headphones when you speak.
datagrok /
Last active Aug 29, 2015
Table-of-contents generator in coffeescript + jQuery
# Copyright 2015 Michael F. Lamb
# License: AGPLv3+
# Uses heading data in the document to generate a nested unordered list with links to the headings.
# Assumes headings already have ids set.
# Requires jQuery.
buildTOCLinks = (os) ->
return if os?.length == 0
datagrok /
Last active Sep 18, 2015
Questions while reading stuff


__debug__ vs. -O

Python has a built-in variable __debug__ which is set to True when python is called without -O (optimize). The -O flag disables all assertion code.

This seems at first glance like a very easy and clean construct to rely on when coding in development versus production: in development, don't use -O, defensively litter your code with type- and sanity-checking asserts. Perform development-only debugging by testing __debug__ beforehand.

When in production, run all code is run with -O which disables asserts (speeding execution) and sets __debug__ to False.

datagrok / gist:951011
Created May 2, 2011
"Link-bar" creation bookmarklet
View gist:951011
// This bookmarklet provides a way to navigate "related link" tags, like <link rel="Prev"... /> <link rel="Next"... />.
// Copy and paste this into a bookmark:
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src=""+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.5.2",function($,L){var d=$("<div/>");$("link").each(function(){d.append($("<a/>").attr("href",$(this).attr("href")).text("["+$(this).attr("rel")+"] "+$(this).attr("title")));d.append("<br/>")});$("body").prepend(d);});
// Original source, before minifying and JQuery-enabling.
// minify:
// jQuery-enabling:
var d = $('<div/>');
datagrok /
Last active Sep 27, 2015
Anime Favorites

I began to want a tabular format and Github-flavored-markdown was becoming too tedious, so I moved this to Google Docs: datagrok's anime favorites

Text below is not yet incorporated into that spreadsheet


  • Anything with music by Susumu HIRASAWA (= Anything written, directed, or animated by Satoshi KON).
  • Anything with music by Yoko KANNO.
datagrok /
Created Oct 30, 2011
Build an xterm color palette procedurally generated from some given color.
"""Colorscheme builder
Future improvements: Twisting the 'hue' knob in HSV
colorspace isn't necessarily the best way to procedurally
choose colors. I'd like to explore the use of other
"perceptual" colorspaces like L*A*B* for calculating
uniform hue spreads.
datagrok / output.html
Created Oct 30, 2011
Create a sparkline chart, render to .png, embed into a line of text as a data: URI
View output.html
p {width: 20em;}
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Does my
sparkline <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAAPAgMAAADFfETiAAAADFBMVEX/////AACAbIAAAAAe6DapAAAAWUlEQVR42m3OKw7AQAgE0BEVc6wVK3osRAXH7vBZUlHEwEsgAQtZu/LCjyPCdkyZYzt27AfLfGwyZF+GtE7Sd9llKp3RybZZTGO2tacnSIzZzvga5a5yNOAFUsco8dm3E2wAAAAASUVORK5CYII="> fit in a nice paragraph of text? Ut enim
datagrok /
Created Mar 4, 2012
Trying to figure out how best to asynchronously build an object from an asynchronous function and array of keys.
assert = require 'assert'
# Imagine some function fn(x). For example:
fn = (x) -> x+1
# We want to build from a given Array of keys an Object whose values represent
# the result of that asyncronous function. For example,
input_keys = [