Skip to content

Instantly share code, notes, and snippets.

@tricknotes
tricknotes / benchmark.js
Created Dec 10, 2012
Performance check about arguments with EventEmitter
View benchmark.js
var EventEmitter = require('events').EventEmitter
var i;
var count = 100000000;
var e = new EventEmitter();
e.on('hi', function() {});
now = Date.now();
for (i = 0; i < count; i++) {
e.emit('hi');
@tricknotes
tricknotes / benchmark.js
Created Dec 10, 2012
Performance check about arguments
View benchmark.js
var now;
var fn, i;
var count = 10000000;
now = Date.now();
fn = function() {
arguments[0];
}
for (i = 0; i < count; i++) {
fn();
@tricknotes
tricknotes / bench.js
Created Dec 8, 2012
Performance check about deleting property null assignment
View bench.js
var now;
var obj, i;
var count = 10000000;
var key = 'key';
obj = {};
now = Date.now();
for (i = 0; i < count; i++) {
obj[key] = 1;
obj[key] = null;
@tricknotes
tricknotes / bench.js
Created Dec 5, 2012
Performance check about object initialization.
View bench.js
var before, after;
var obj, i;
var count = 1000000000;
var t;
console.log('%j', process.versions);
console.log('');
console.log('* initialize');
@tricknotes
tricknotes / printout.js
Created Oct 31, 2012
Gist を印刷する時に良い感じのレイアウトにする
View printout.js
// For printout https://gist.github.com
// DOM
$('#header').remove();
$('#repos').remove();
$('.secondary').remove();
$('.meta').remove();
$('#footer').remove();
$('.push').remove();
$('#comments').remove();
@tricknotes
tricknotes / zenkaku_hankaku.js
Created Oct 14, 2012
JavaScript での全角・半角の正規表現
View zenkaku_hankaku.js
// see: http://gimite.net/gimite/rubymess/moji.html
var zenkaku = /(?:[ !”#$%&’()*+,-./:;<=>?@[¥]^_‘{|} ̄])|(?:[、。・゛゜´`¨ヽヾゝゞ〃仝々〆〇ー―‐\~〜∥…‥“〔〕〈〉《》「」『』【】±×÷≠≦≧∞∴♂♀°′″℃¢£§☆★○●◎◇◇◆□■△▲▽▼※〒→←↑↓〓])|(?:[0-9])|(?:[A-Z])|(?:[a-z])|(?:[ぁ-ん])|(?:[ァ-ヶ])|(?:[Α-Ωα-ω])|(?:[А-Яа-я])|(?:[\u2570-\u25ff])|(?:[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/;
var hankaku = /(?:[\x00-\x1f\x7f])|(?:[ !"#$%&'()*+,\-.\/:;<=>?@\[\\\]\^_`{|}~])|(?:[\uFF61\uFF62\uFF63\uFF64\uFF70\uFF9E\uFF9F\uFF65])|(?:[0-9])|(?:[A-Z])|(?:[a-z])|(?:[\uFF66-\uFF6F\uFF71-\uFF9D])/;
View gist:2793995
PROMPT="function %n() { "
RPROMPT="};"
View quota_exceeded_error.json
{ [MongoError: quota exceeded]
name: 'MongoError',
err: 'quota exceeded',
code: 12501,
n: 0,
lastOp: { low_: 2, high_: 1324977215 },
connectionId: 64862,
ok: 1 }