records -> knowledge
autonomous driving
/*** | |
* 这是一个测试与向导程序。 | |
* 如果未开启mongoDB,则无需任何改变,可以运行一个nodejs的“hello world”小程序。 | |
* 如果开启了mongoDB,则去config.js文件按指引操作,可以运行获得一个通过mongoskin模块连接的nodejs+mongodb测试小程序。 | |
***/ | |
var http = require('http'), | |
db = require('./config').db; | |
http.createServer(function(req, res){ | |
res.writeHead(200, {"content-type":"text/html;charset=utf8"}); | |
if(db){ |
/** | |
* 复制对象、数组 | |
* @param {Object} obj [原始对象] | |
* @return {Object} [复制的对象] | |
*/ | |
function clone(obj){ | |
var objClone; | |
if (obj.constructor == Object){ | |
objClone = new obj.constructor(); | |
}else{ |
#include <node.h> | |
#include <v8.h> | |
#include <node_buffer.h> | |
#include <iostream> | |
using namespace std; | |
using namespace v8; | |
using namespace node; | |
Handle<Value> test(const Arguments& args) { | |
HandleScope scope; |
#include <node.h> | |
#include <v8.h> | |
#include <node_buffer.h> | |
#include <iostream> | |
using namespace std; | |
using namespace v8; | |
using namespace node; | |
Handle<Value> slowBuffer(const Arguments& args) { | |
HandleScope scope; |
/*! | |
* dump.js, dump mongodb. | |
* Copyright(c) 2012 Taobao.com | |
* Author: busi.hyy <[email protected]> | |
* | |
* 每天凌晨3点从mongo dump一份到指定文件夹,前缀为20121113_ | |
* 只保留最近七天的dump文件 | |
* Example: `node dump 127.0.0.1:27071 back database collection1 collection2 ...` | |
*/ |
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'; |
records -> knowledge
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, |