Skip to content

Instantly share code, notes, and snippets.

// http://bitwiseshiftleft.github.io/sjcl/doc/
var crypto = require('crypto'),
sjcl = require('sjcl');
//----------------------------------------------------------------------
var key = new Buffer('RB9xQTAaqvRs8OW4t5/M/RBWEAjq/ur73EeDV06cfGI=', 'base64'),
iv = new Buffer('jwM1m/dPQnA5Ke9I', 'base64'),
n_0 f x = x
n_1 f x = f x
n_2 f x = f (f x)
n_3 f x = f (f (f x))
n_4 f x = f (f (f (f x)))
inc n f x = f (n f x)
add m n f x = m f (n f x)
mul m n f = m (n f)
ex m n = n m
require './turing'
B = Turing::BLANK
increment = Turing::Machine.new([
[1, 0, 1, :R, 2],
[1, 1, 0, :L, 1],
[1, B, 1, :R, 2],
[2, 0, 0, :R, 2],
[2, 1, 1, :R, 2],
#!/bin/bash
function how-big-is {
local library="$1"
npm install "$library" uglifyjs webpack
echo "require('$library')" > index.js
./node_modules/.bin/webpack . build.js
./node_modules/.bin/uglifyjs build.js -cmo build-min.js 2> /dev/null
gzip -c build-min.js > build-min.js.gz
ls -lh build*
type Peg = [Int]
data Game = Game { a :: Peg, b :: Peg, c :: Peg } deriving (Show)
type Sel = Game -> Peg
initPegs :: Int -> Game
initPegs n = Game { a = [n, (n-1) .. 1], b = [], c = [] }
hanoi :: Int -> Game -> Game
hanoi 1 Game { a = a, b = b, c = c } =
function asyncMap(array, fn, callback) {
if (array.length === 0) return callback([]);
let res = [], c = 0;
array.forEach((item, index) => {
fn(item, (result) => {
res[index] = fn(item);
if (++c === array.length) callback(res);
});
SCREEN 12
FOR c = 0 TO 15
d% = 4.2 * c
PALETTE c, 65793 * d%
NEXT c
ox = 320
oy = 280
xs = 220
#!/bin/bash
set -e
RUBY_INSTALL_VERSION="0.6.0"
CHRUBY_VERSION="0.3.9"
RUBY_VERSIONS="1.9.3-p551 2.0.0-p648 2.1.10 2.2.5 2.3.1"
RUBIES_DIR="/opt/rubies"
LATEST_RUBY="2.3.1"
const getAllPropertyNames = require('./get_all_property_names'),
Mutex = require('./mutex')
function actor(object) {
let methods = getAllPropertyNames(object),
mutex = new Mutex(),
wrapper = {}
for (let method of methods) {
if (typeof object[method] !== 'function') continue
var Mutex = function() {
this._busy = false;
this._queue = [];
};
Mutex.prototype.synchronize = function(task) {
var self = this;
return new Promise(function(resolve, reject) {
self._queue.push([task, resolve, reject]);