Skip to content

Instantly share code, notes, and snippets.

View chenzhihao's full-sized avatar

Zhihao Chen chenzhihao

View GitHub Profile
@chenzhihao
chenzhihao / gist:5982544
Created July 12, 2013 07:20
kill process quickly
ps -ef|grep node|grep -v grep|awk {'print $2'}|xargs kill -9
function onRequest(request, response) {
var pathName = url.parse(request.url).pathname;
handler[pathName];
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
function onRequest(request, response) {
var pathName = url.parse(request.url).pathname;
handler[pathName];
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
@chenzhihao
chenzhihao / app.js
Created December 4, 2013 04:47
post type check
function JSONOnly(req, res, next) {
console.log(req.header('accept'));
console.log(req.is('json'));
if (!req.is('json')) {
res.send(406);
}
else {
next();
}
@chenzhihao
chenzhihao / boxes
Last active August 29, 2015 14:03
a html for browser event mechanism description
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
background-color: #f1f4f9;
padding: 50px;

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
find . -type f -name *.flac -exec rm {} \;
function tunkfiedSettimeOut(delay,index) {
return function(cb) {
console.log('index: ',index);
setTimeout(function(){
cb(undefined,delay);
},delay);
}
}
tunkfiedSettimeOut(3000,1)(function(err,data){console.log("delay is", data)});

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@chenzhihao
chenzhihao / 0_reuse_code.js
Created January 9, 2017 05:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console