Skip to content

Instantly share code, notes, and snippets.

View lsongdev's full-sized avatar
👨‍💻
Thinking ...

Lsong lsongdev

👨‍💻
Thinking ...
View GitHub Profile
#!/usr/bin/env bash
#
LOG_DIR=/var/sankuai/logs/myfe-canary
#
DATE=$(date +%F)
PID="$LOG_DIR/myfe-canary-0.pid"
#
LOG_STDOUT="$LOG_DIR/stdout.log"
@lsongdev
lsongdev / gist:b8b739468a6937c7e8db
Last active September 29, 2015 06:05 — forked from netwjx/output
统计最近一段时间git版本库中代码提交量
git log '@{1 weeks ago}..HEAD' --shortstat --pretty=format:%an | awk '/.+/ {
if($2 != "file" && $3 != "changed,") {
curr = $1
} else {
files[curr]+=$1
inserts[curr]+=$4
deletes[curr]+=$6
}
}
END {
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
atom.workspace.observeTextEditors (editor) ->
editor.onDidSave ->
URL.prototype.__defineGetter__('query', function() {
var params = {};
this.search.substr(1).split('&').map(function(param){
var pair = param.split('=');
params[ pair[0] ] = pair[1];
});
return params;
});
//jweixin-1.0.0.js
! function(g, initFunc) {
'function' == typeof define && (define.amd || define.cmd) ? define(function() {
return initFunc(g)
}) : initFunc(g, true)
}(this,
function(glob, setGlobal) {
function invokeCmd(cmd, param, callbackObj) {
glob.WeixinJSBridge ? WeixinJSBridge.invoke(cmd, normParameter(param), function(res) {
completeBridgeInteraction(cmd, res, callbackObj);
#!/usr/bin/env bash
# put your hosts file into /etc/hosts.d/
#
# usage:
# chhost $your-host-name
# restore:
# chhost
HOSTD=/etc/hosts.d
var tmpl = function(str, data){
return str.replace(/#{([\s\S]*?)}/g, function(matchs, key){
return data[key.trim()] || '';
});
};
tmpl("My name is #{name} .", { name: 'lsong' });
@lsongdev
lsongdev / fire.sh
Last active August 29, 2015 14:23
#!/usr/bin/env bash
# curl -so /usr/local/bin/fire https://gist.githubusercontent.com/song940/0af7aeadbea766bd8a63/raw/fire.sh && chmod +x /usr/local/bin/fire && echo "> DONE"
#
# usage: fire [PORT]
#
REMOTE_HOST=www.lsong.org
REMOTE_PORT=$RANDOM
REMOTE_USER="lsong"
var arr = [
{id:1, pid:0, name:"SYSTEM"},
{id:2, pid:1, name:"aa"},
{id:3, pid:2, name:"aaa"},
{id:4, pid:2, name:"b"},
{id:5, pid:0, name:"c"},
{id:6, pid:5, name:"cc"}
];
function generateTree(arr) {
@lsongdev
lsongdev / path-helper.sh
Last active December 25, 2015 11:44
auto load PATH config from /etc/path.d/*
#!/usr/bin/env bash
PATH_DIR=/etc/path.d
for file in $(ls $PATH_DIR); do
for line in $(cat "$PATH_DIR/$file"); do
PATH=$PATH:$line
done
done