Skip to content

Instantly share code, notes, and snippets.

var code = '(1 2 (3 4 "h\"i"))'
function parse_lisp(code) {
var tokens = code.match(/\(|\)|\d+|"[^"]*"/g)
var tree = []
function parse_array() {
var code = '["do", ["set", "x", 0], ["while", ["<", ["get", "x"], 10], ["set", "x", ["+", ["get", "x"], 1]]]]'
function parse_lisp(x) {
return JSON.parse(x)
}
console.log('hi')
var lisp_variables = {}
pragma solidity ^0.4.0;
contract TicTacToe {
struct Game {
address[2] players;
uint256 prize_pool;
uint256[9] board;
}
@dglittle
dglittle / gist:5440598
Last active December 16, 2015 13:19
a function for fiberizing and defiberizing stuff that I plan to use later, maybe (untested)
_.fiberize = function (x) {
if (typeof(x) == 'object') {
for (var k in x)
if (typeof(x[k]) == 'function')
x[k] = _.fiberize(x[k])
return x
} else if (typeof(x) == 'function') {
return function () {
var args = _.toArray(arguments)
args.push(_.p())
@dglittle
dglittle / gist:5429091
Created April 21, 2013 09:40
highlightDiff function for highlighting the differences between two strings using html. The differences are highlighted with yellow spans.
// example:
// var ret = highlightDiff("hello earth", "hello mars")
// console.log(ret)
// {
// "a": "hello <span style=\"background-color:yellow\">earth</span>",
// "b": "hello <span style=\"background-color:yellow\">mars</span>"
// }
function highlightDiff(a, b) {
a = a.match(/\w+|\S+|\s+/g)
@dglittle
dglittle / gist:5042589
Last active December 14, 2015 06:29
csv parser and outputter
_.csv = function (data, headers) {
if (headers === undefined) headers = true
if (typeof(data) == 'object') {
var s = []
function escapeCsv(s) {
if (s.match(/[,"\n]/))
return '"' + s.replace(/"/g, '""') + '"'
return s
}
function escapeLine(a) {