This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In Java, it is possible to drop the `this` in front of instance variables | |
*/ | |
class Example{ | |
private int foo; | |
public Example(int bar){ | |
foo = bar; | |
} | |
public int getFoo(){ | |
return foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(global){ | |
var MathUtils = { | |
powermod: function powermod(num, exp, mod){ | |
if(exp === 1) return num % mod; | |
if(exp & 1 === 1){ //odd | |
return (num * powermod(num, exp-1, mod)) % mod; | |
} | |
return Math.pow(powermod(num, exp/2, mod), 2) % mod; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
class sort{ | |
public static void main(String[] a){ | |
Sorter[] list = {new InsertionSort(), new BubbleSort(), new QuickSort()}; | |
for(int i = 0; i < list.length; i++){ | |
sort.perform(list[i]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var inspect = function(obj, showHidden, depth, colors){ | |
var ctx = { | |
style: /*colors ? stylyze : */function(a){return a;}, //todo | |
seen: [] | |
}; | |
return formatValue(ctx, obj, 2); | |
} | |
var _reName = /(\n\s+)"([A-Za-z_$][\w$]*)"/g; | |
var _reValue = /\"([^\n]*)\"(?=,?\n)/g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RSAencrypt{ | |
static public double m; | |
static public double publicK; | |
static private double privateK; | |
static private double nums = 6; | |
static{ | |
double p = ranPrime.genRanPrime(nums); | |
double q = ranPrime.genRanPrime(nums); | |
RSAencrypt.m = p * q; | |
double phi = (p-1) * (q - 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Dependencies: | |
* Request (npm install request) | |
* readabilitySAX (npm install readabilitySAX) | |
* my htmlparser fork (https://github.com/FB55/node-htmlparser) | |
*/ | |
var request = require("request"), | |
readability = require("./readabilitySAX"); | |
Parser = require("node-htmlparser/lib/Parser.js"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple feedparser | |
Based upon: | |
- https://raw.github.com/drudge/node-easyrss | |
*/ | |
var sax = require('./libs/sax'); | |
module.exports.streamParser = function(){ |
NewerOlder