Skip to content

Instantly share code, notes, and snippets.

View dead-horse's full-sized avatar
🤖
I may be slow to respond.

Yiyu He dead-horse

🤖
I may be slow to respond.
View GitHub Profile
Command.prototype.executeSubCommand = function(argv, args, unknown) {
args = args.concat(unknown);
if (!args.length) this.help();
if ('help' == args[0] && 1 == args.length) this.help();
// <cmd> --help
if ('help' == args[0]) {
args[0] = args[1];
args[1] = '--help';

Data Mining

records -> knowledge

hard by human

autonomous driving

local file = io.open("urls.txt", "r");
local arr = {}
local lines = file:lines()
for line in file:lines() do
table.insert (arr, line);
end
local i = 0
request = function()
i = (i % #arr) + 1
return wrk.format(nil, arr[i])
#! /bin/sh
while [ 1 ]
do
START=$(($(date +%s%N)/1000000))
curl -s -i http://localhost:3000 | grep X-Response-Time
END=$(($(date +%s%N)/1000000))
var mkdirp = require('mkdirp');
var http = require('http');
var fs = require('fs');
var path = require('path');
var tmp = path.join(__dirname, 't.tgz');
var opts = {
hostname: 'cnpm.oss.aliyuncs.com',
method: 'GET',
port: 80,
@dead-horse
dead-horse / http_keepalive_async.js
Last active August 29, 2015 14:05
pipe bug in node 0.10.30
var http = require('http');
var fs = require('fs');
var path = require('path');
var tmp = path.join(__dirname, 't.tgz');
var opts = {
hostname: 'registry.npmjs.com',
method: 'GET',
port: 80,
path: '/cutter/-/cutter-0.0.3.tgz',
@dead-horse
dead-horse / bench.js
Created August 23, 2014 16:20
co benchmark for thunk and promise
var benchmarks = require('beautify-benchmark');
var Benchmark = require('benchmark');
var thunkify = require('thunkify');
var zlib = require('zlib');
var co = require('co');
var fs = require('fs');
var gzipPromise = require('mz/zlib').gzip;
var gzipThunk = thunkify(zlib.gzip);
var fsPromise = require('mz/fs');
var path = require('path');
var simplePath = '/home/Users/deadhorse/git/node/lib/path.js';
var pathWithDot = '/home/Users/deadhorse/git/node/./lib/./path.js';
var pathWithDotDot = '/home/Users/deadhorse/git/node/../lib/../path.js';
var length = 1000000;
console.time('normalize simple path');
for (var i = 0; i < length; i++) {
function test(path) {
return path.split('/').join('/');
}
var path1 = 'first';
var path2 = 'second';
var longPath = '.././home//Users/name/git/project/lib/abc/def/zzz.js';
var plusPath = path1 + '/' + path2 + '/' + longPath;
var constantPath = 'first/second/.././home//Users/name/git/project/lib/abc/def/zzz.js';
var cp = require('child_process');
var urllib = require('urllib');
exports.ipMap = {};
var urls = [
'www.baidu.com',
'www.tmall.com'
];