Skip to content

Instantly share code, notes, and snippets.

View wondger's full-sized avatar
😇

wondger wondger

😇
View GitHub Profile
@wondger
wondger / .gitconfig
Created March 11, 2014 12:46
.gitconfig
[user]
name = wondger
email = [email protected]
[alias]
st = status
co = checkout
cob = checkout -b
ca = commit --amend
last = log --graph -1 HEAD
aa = add .
@wondger
wondger / .bashrc
Created July 2, 2013 06:06
mac iterm path info(can display current git branch)
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
#PS1='\u@\w $ '
PS1="\[\e[32;22m\]\u\[\e[35;22m\]@\[\e[36;22m\]\w\[\e[36;1m\]\[\e[0;33m\]\$(parse_git_branch)\[\e[0m\] $ \[\e[0m\]"
@wondger
wondger / foreRequire.js
Created October 12, 2012 08:56
reload nodejs module without cache
function foreRequire(module) {
delete require.cache[path.resolve(module)];
return require(module);
}
@wondger
wondger / readDir.js
Created October 11, 2012 08:01
recursive read directory and return all files and directories.
var utils = {
isFile: function(path) {
var stat = fs.statSync(path);
return stat ? stat.isFile() : undefined;
},
isDir: function(path) {
var stat = fs.statSync(path);
return stat ? stat.isDirectory() : undefined;
},
readDir: function(dir, callback) {
@wondger
wondger / svn-auto-update
Created September 26, 2012 01:52
TortoriseSVN auto update
@echo auto update start!
@echo off&setlocal enabledelayedexpansion
:loop
@ping 127.0.0.1 -n 600 > nul
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:update /path:"d:/work/FETest/code/" /closeonend:3
@echo [%DATE% %TIME%] update success
goto loop
@wondger
wondger / new.js
Created August 20, 2012 16:05
express vhost
var express = require('express');
var s1 = require('./site1/app.js')
,s2 = require('./site2/app.js')
,s3 = require('./site3/app.js')
,s4 = require('./site4/app.js')
,s5 = require('./site5/app.js')
,s6 = require('./site6/app.js')
@wondger
wondger / Split.js
Created May 27, 2012 15:10
packet
/*
* @name:SplitURI.js
* @description:分割URL
* 最小分割单元为12个字符长度,UTF8编码中可能存在4个字节编码的字符
* UTF8各字节字符编码最大值:
* 单字节字符:0-127
* 其他字节字符末字节:128-191
* 双字节字符首字节:192-223
* 三字节字符首字节:224-239
* 四字节字符首字节:240-247
@wondger
wondger / GUID.js
Created May 3, 2012 16:49
GUID by JavaScript
var guid = (function(){
function S4(){return(((1+Math.random())*65536)|0).toString(16).substring(1)}
return function guid(){return(S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()).toUpperCase()}
})();
/*
* @name:JSON.js
* @description:
* @author:[email protected]
* @date:2012-05-02
* @param:
* @todo:
* @changelog:
*/
window.JSON = window.JSON || {
@wondger
wondger / LevenshTeinDistance.js
Created April 26, 2012 17:43
LevenshTeinDistance
/*
* @name:LevenshteinDistance.js
* @description:
* @author:[email protected]
* @date:2012-04-17
* @param:
* @todo:
* @changelog:
*/
var LevenshteinDistance = {