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
[obj] [structure] [property] [value] | |
test_article none title A Test Article | |
test_article none content Hello world! | |
test_article tags 0 misc | |
test_article tags 1 etc | |
test_article comments.0 poster_name AvgJoe | |
test_article comments.0 content This article is amazing | |
test_article comments.1 poster_name SuperNerd | |
test_article comments.1 content No it's not! | |
another_article none title Another Article |
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 a = []; | |
for (var i = 0; i < 100000; i++) a.push('a'); | |
var o = {}; | |
for (var i = 0; i < 100000; i++) o['key_' + i] = 'a'; | |
(function() { | |
var s = Date.now(); | |
var i = a.length; | |
while (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
(function() { | |
var start = Date.now(); | |
var i = 1000000; | |
while (i--) { | |
var str = ''; | |
str += 'a'; | |
str += 'a'; | |
str += 'a'; | |
str += 'a'; | |
str += 'a'; |
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 times = 15000; | |
(function() { | |
var i = 0, start = Date.now(); | |
(function() { | |
if (++i < times) arguments.callee.call(); | |
})(); | |
console.log('callee', Date.now() - start); | |
})(); |
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 http = require('http') | |
, parse = require('url').parse | |
, StringDecoder = require('string_decoder').StringDecoder; | |
var LIMIT = 10 * 1024; | |
var request = function(url, body, func) { | |
if (typeof url !== 'object') { | |
url = parse(url); | |
} |
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
// a shim to fix base64 cipher output, untested | |
var Cipher = require('crypto').Cipher; | |
var update = Cipher.prototype.update, | |
final = Cipher.prototype.final; | |
Cipher.prototype.update = function(data, input, output) { | |
if (output === 'base64') { | |
data = update.call(this, data, input, 'binary'); | |
return new Buffer(data, 'binary').toString('base64'); |
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
// ignore the shims | |
// the original (slow) version | |
var Buffer1 = (function() { | |
var assert = {}; | |
var fail = function() { throw new Error('assertion failed'); }; | |
var Buffer = function() { this.length = 100; }; | |
Buffer.prototype.writeUInt32 = function(value, offset, endian) { | |
var buffer = this; |
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() { | |
var bench = function(func, t) { | |
var start = new Date() | |
, i = t || 100000; | |
while (i--) func(1, 2, 3); | |
console.log('%s: %sms', func.name, new Date() - start); | |
}; | |
var slice = Array.prototype.slice; | |
bench(function _slice() { |
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
a poem about coffeescript in the style of the lord of the rings: | |
one does not simply walk into coffeescript | |
its syntax is guarded by more than just ruby devs | |
and the significant whitespace is ever present | |
it is a wasteland barren of curly braces | |
- riddled with class syntax, postfix conditionals, and operator aliases | |
the very code you write, is a poisonous fume | |
not with 10,000 men who knew javascript could you do this |
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 fs = require('fs') | |
, marked = require('marked'); | |
var text = fs.readFileSync(__dirname + '/test.md', 'utf8'); | |
var two = function(str) { | |
var tokens = marked.lexer(str) | |
, paragraphs = 0 | |
, i = 0 | |
, token; |
OlderNewer