Skip to content

Instantly share code, notes, and snippets.

@jiangzhuo
jiangzhuo / gist:fb61ddd9c1bb0cba6b30
Last active January 8, 2016 15:30
UpdateFuncWithSB.js
var vm = require('vm');
var util = require('util');
var express = require('express');
var bodyParser = require('body-parser');
var multer = require('multer'); // v1.0.5
var upload = multer(); // for parsing multipart/form-data
var app = express();
app.use(bodyParser.json()); // for parsing application/json
@jiangzhuo
jiangzhuo / myhomevod.js
Created December 5, 2015 15:40
myhomevod through qq
//var list=
var Browser = require('nodecast-js');
var DeviceWatcher = require('upnp-device-client');
var util = require('util');
var browser = new Browser();
var deviceList = [];
var currentDevice = '';
var playList = [];
var currentSong;
var gid = 2178625976;
--quiet # 安静输出
--port arg # 指定服务端口号,默认端口27017
--bind_ip arg # 绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定默认本地所有IP
--logpath arg # 指定MongoDB日志文件,注意是指定文件不是目录
--logappend # 使用追加的方式写日志
--pidfilepath arg # PID File 的完整路径,如果没有设置,则没有PID文件
--keyFile arg # 集群的私钥的完整路径,只对于Replica Set 架构有效
--unixSocketPrefix arg # UNIX域套接字替代目录,(默认为 /tmp)
--fork # 以守护进程的方式运行MongoDB,创建服务器进程
--auth # 启用验证
yum install gnuplot
// we can get distribution address at http://www.apache.org/dyn/closer.cgi/hbase/
wget http://apache.fayea.com/hbase/hbase-0.98.12/hbase-0.98.12-hadoop1-bin.tar.gz
tar xfz hbase-0.98.12-hadoop1-bin.tar.gz
cd hbase-0.98.12-hadoop1
# vim /usr/local/hbase/conf/hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel/kptr_restrict=0

perf record -i -g -e cycles:u -- ~/sources/node/node --perf-basic-prof script.js

perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' | ~/sources/FlameGraph/stackcollapse-perf.pl > out.perf-folded
@jiangzhuo
jiangzhuo / gist:953f3054c8814ffbc0ea
Created April 10, 2015 09:19
create vpn server on CentOS6 with one command
wget http://www.hi-vps.com/shell/vpn_centos6.sh
sh vpn_centos6.sh
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
typedef int32_t Score;
typedef int32_t UserId;
typedef int32_t Rank;
const Score kInvalidScore = -1;
http://superuser.com/questions/127863/manually-closing-a-port-from-commandline
db.areas.aggregate(
[
{
$project: {
areaId: 1,
numberOfResource: { $size: "$resources" }
}
}
]
)