Skip to content

Instantly share code, notes, and snippets.

View bwestergard's full-sized avatar

Björn Westergard bwestergard

  • Mt. Pleasant, Washington, D.C.
View GitHub Profile
@bwestergard
bwestergard / bookmark.py
Created January 11, 2012 15:18
A python script to let you read a book (e.g. a dictionary, an encyclopedia) in random order, keeping track of which pages have already been read.
import sys,random
'''
USAGE
Let's say you want to read The Oxford Companion to Lulz, which has 819 pages. You would create a file with one line, "1:819", and save it as lulz.txt. Then you would run:
python bookmark.py lulz.txt
This would return a random page that you haven't yet read. Let's say it was 42. You then read from 42 to 50. You record this fact by running:
@bwestergard
bwestergard / x.js
Last active December 25, 2015 22:39
Cassini Do It Yourself (Attempted Fix)
// Cassini projection
// just a transverse equirectangular projection
// implemented from wikipedia description
d2r = Math.PI / 180;
return Math.asin(Math.sin(x * d2r) * Math.cos(y * d2r));
var env = process.env;
var cfg = {
foo: env.FOO_QUEUE || 'foo',
pattern: env.BIND_QUEUE_PATTERN,
amqpUrl: env.RABBIT_MQ_URL
};
cfg.channel = {
// Channel method to invoke
[
{
"id": 0,
"description": "Science In Action",
"tags": "read philosophy",
"dependencies": [6]
},
{
"id": 1,
"description": "Conscience of the Revolution",
@bwestergard
bwestergard / example.js
Last active August 29, 2015 14:26
Ramda "supercompiler"
// Ramda provides one, but just for verbosity
var add = function (x,y) { return x + y; };
var square = function (x) { return x * x; };
// Redundant looping
var sumSquares = R.pipe(
R.map(square),
R.reduce(add, 0)
);
@bwestergard
bwestergard / bibliography.md
Last active November 27, 2015 22:30
Surplus Population Bibliography
@bwestergard
bwestergard / ubi.md
Last active December 15, 2015 19:23
Basic Income Bibliography
@bwestergard
bwestergard / json_populate_recordset.md
Created February 29, 2016 22:23
json_populate_recordset example
lanetix=# \d foo
           Table "scripting.foo"
 Column |         Type          | Modifiers 
--------+-----------------------+-----------
 id     | integer               | not null
 a      | character varying(40) | not null
 b      | character varying(40) | not null
 c      | character varying(40) | not null
udpPort.send({
address: '/s_new',
args: ['ping', 400]
}, '127.0.0.1', 57110)