Skip to content

Instantly share code, notes, and snippets.

@gloryofrobots
gloryofrobots / nano_lisp.js
Last active December 29, 2015 01:48
Simple lisp interpreter written on js. It supports js numbers, "lambda", "define", "if", "set!"
function _make_function(args, body) {
return new Function(args, body);
}
// helpers
var $ = _make_function("id" ,"return document.getElementById(id)")
var _isarray = _make_function("obj","return obj instanceof Array;")
var _error = _make_function("txt", "throw new Error(txt)")
var _is_undefined = _make_function("obj","return obj == undefined")
function _add_repr_to_object (o, r) {
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"