Skip to content

Instantly share code, notes, and snippets.

@zenozeng
zenozeng / gitlog.js
Created December 31, 2014 08:50
gitlog.js
var cp = require('child_process');
module.exports = function(dir, callback) {
// Note: don't use string to concat json, for commit subject may contain ' or "
var sep = "<_______GITLOG COMMITS START_________>";
var pretty = sep + ["%s", "%an", "%ae", "%ai"].join('%n');
var gitlog = cp.spawn('git', ['log', '--pretty=' + pretty, '--name-only'], {cwd: dir});
var stdout = '',
stderr = '';
var watch = require('node-watch'),
exec = require('child_process').exec;
watch('.', { recursive: true, followSymLinks: true }, function(filename) {
if(filename === "build.js") return;
console.log(filename, ' changed.');
exec('./build.sh', function(error, stdout, stderr) {
if(stdout) console.log('stdout: ' + stdout);
if(stderr) console.log('stderr: ' + stderr);
if (error !== null) {
@zenozeng
zenozeng / sort-array-by-array.js
Last active August 29, 2015 14:05
javascript
// Sort by fitness
// JSON.stringify([[5, 3], [2, "string"], [4, 1]].sort())
// "[[2,"string"],[4,1],[5,3]]"
// `a` and `b` are sorted by `a.toString()` - `b.toString()`
// See also: http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.11
// 所以是不靠谱的:
// ["190", (2000000000000000000000000).toString(), (1000000000000000000000000000000000000).toString()].sort()
// ["190", "1e+36", "2e+24"]
this.population = this.population.map(function(individual) {
@zenozeng
zenozeng / restart-gnome-shell-from-tty.sh
Created April 27, 2014 17:07
Restart gnome-shell from tty
gnome-shell -r --display=:0
@zenozeng
zenozeng / ssh-via-ssh.sh
Created April 6, 2014 08:44
ssh via ssh
ssh -A -t -p 23 server1 ssh -A server2
@zenozeng
zenozeng / remove-title-bar.sh
Created February 9, 2014 11:28
remove title bar using xprop
xprop -id $xid -f _MOTIF_WM_HINTS 32c -set _MOTIF_WM_HINTS "0x2, 0x0, 0x0, 0x0, 0x0"
@zenozeng
zenozeng / eval.js
Created January 27, 2014 05:01
eval.js
(Function(string))();
@zenozeng
zenozeng / gist:8578486
Created January 23, 2014 13:32
瀑布流
CSS3 Multiple Columns 拿来做瀑布流和响应式非常容易,除了栏必须是竖着的会影响排序这一点。
@zenozeng
zenozeng / 10.76.8.61
Last active January 3, 2016 21:09
IP Route for songsong and auto setup script
ip route add 10.76.8.61 via 192.168.1.1 dev br-wan