Skip to content

Instantly share code, notes, and snippets.

View fb55's full-sized avatar

Felix Boehm fb55

View GitHub Profile
@fb55
fb55 / helper.js
Created May 13, 2012 20:52
Dropbox Dropquest Chapter 21
var encode = {
1: function(str){
return str
.split("")
.filter(function(s){
return !{D:1, R:1, O:1, P:1, B:1, X:1}[s];
}).join("");
},
2: function(str){
return str.split("").map(function(s){
@fb55
fb55 / parse.js
Created May 15, 2012 08:00
Node querystring module test
var newQS = require("./new.js"),
oldQS = require("./old.js"),
bench = require("bench");
//taken from https://github.com/joyent/node/blob/master/test/simple/test-querystring.js
var tests = ["foo=918854443121279438895193", "foo=bar", "foo=bar&foo=quux", "foo=1&bar=2", "my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F", "foo%3Dbaz=bar", "foo=baz=bar", "str=foo&arr=1&arr=2&arr=3&somenull=&undef=", " foo = bar ", "foo=%zx", "foo=%EF%BF%BD", "hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz", "foo&bar=baz"];
exports.compare = {
"parse from new qs": function(){
return tests.map(newQS.parse);
@fb55
fb55 / gist:3737020
Created September 17, 2012 12:28
ClosingTags
/*
Tags that have a special meaning in HTML
Every tag can have the following properties:
* parent: A list of all possible parent nodes. If none is present, the tag is wrapped in the first one.
* prev: A list of tags that need to preceed the tag. If they don't exist, they are created.
* past: A list of tags that needs to follow the tag.
* close: A list of elements that are closed when the tag appears. Only walks until it finds the next required parent.
* children: The possible child nodes. Can be a list, false or "text".
* If a list, it's a list of elements that need to be included in the tag. If they don't exist, they are created.