Skip to content

Instantly share code, notes, and snippets.

@spencertipping
spencertipping / metal-chess-set.md
Last active August 27, 2018 18:26
Metal chess set

A questionably-manufactured metal chess set

It started when Joyce was going to buy a chess set from Amazon. There's nothing wrong with the chess sets there, but they're made of plastic and aren't very interesting. So I offered to make one out of metal instead. Here's what I ended up with:

finished result

finished result

@spencertipping
spencertipping / gist:1219204
Created September 15, 2011 13:22
Strange Ruby behavior
# This example was run in IRB 1.9.2 p290.
# Initialize x, y, z, and t to some values using a parallel assignment:
> x, y, z, t = 1, 2, 3, 4
=> [1, 2, 3, 4]
# In the case above, '=' has lower precedence than ',', so there's a 4-ary
# lvalue and a 4-element rvalue.
> x, y = z, t = 1, 2
@spencertipping
spencertipping / gist:1014640
Created June 8, 2011 15:27
Caterwaul implementation of base-85 encoding
it.encode85(s) = encoded -where [encode_block(n) = n[5] *[String.fromCharCode(33 + n / powers_of_85[4 - x] % 85)] -seq -re- it.join(''),
padded = s.length & 1 ? s + String.fromCharCode(0) : s,
encoded_string = n[0, padded.length, 2] *[encode_block((padded.charCodeAt(x) << 16) >>> 0 | padded.charCodeAt(x + 1))] -seq -re- it.join(''),
encoded = s.length & 1 ? encoded_string.substr(0, encoded_string.length - 2) : encoded_string],
it.decode85(s) = decoded -where [decode_block(n) = String.fromCharCode(n >>> 16) + String.fromCharCode(n >>> 0 & 0xffff),
block_value(s) = n[6] /[x * 85 + s.charCodeAt(x0 - 1) - 33] -seq,
padded = s.length % 5 ? '#{s}uu' : s,
decoded_string = n[0, padded.length, 5] *[decode_block(block_value(padded.substr(x, 5)))] -seq -re- it.join
function () {var left_in = function (x, ops) {return x.xs && x.xs[0] && (ops[x.xs[0].op] && x.xs[0].op ||
x.xs[0].xs && x.xs[0].xs[1] && ops[x.xs[0].xs[1].op] && x.xs[0].xs[1].op)},
right_in = function (x, ops) {return x.xs && x.xs[1] && ops[x.xs[1].op] && x.xs[1].op},
$_ = '';
return '([{'.indexOf(this.op) > -1 ? this.op + s(this.xs[0]) + r.openers[this.op] :
this.op == '?' ? s(this.xs[0]) + ' ? ' + s(this.xs[1].xs[0]) + ' : ' + s(this.xs[2]) :
this.op == '(!' || this.op == '[!' ? s(this.xs[0]) + s(this.xs[1]) :
r.implicit_assignment[this.op] ? '(' + (this.op.char