Skip to content

Instantly share code, notes, and snippets.

View popomore's full-sized avatar
💭
I may be slow to respond.

Haoliang Gao popomore

💭
I may be slow to respond.
  • Alipay Co.
  • Hangzhou China
View GitHub Profile
@popomore
popomore / mod
Created June 13, 2012 20:31
large number modulus fix
function mod(dividend, divisor) {
var sDividend = dividend + '';
var split = sDivisor.length + 1;
// if dividend < 9007199254740992 (2^53)
if (sDividend.length < 16) {
return dividend % divisor;
}
// 'abcdefghijklmnopqrstuvwxyz' => ["qrstuvwxyz", "ghijklmnop", "abcdef"]
@popomore
popomore / gist:3738171
Created September 17, 2012 15:57
upgrade python2.7 in ubuntu

Install Python2.7

$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python2.7 python2.7-dev

Switch Python2.7

@popomore
popomore / gist:3739226
Created September 17, 2012 19:20
jquery data-api

html

<div id="test" data-value="1"></div>

jquery

$('#test').attr('data-value') !== $('#test').data('value');
@popomore
popomore / gist:3783120
Created September 25, 2012 16:55
express 备忘

configure 使用

启动 NODE_ENV=production node app.js

app.configure('development', function(){
  app.set('configPath', './confLocal');
});

app.configure('production', function(){
@popomore
popomore / gist:3792128
Created September 27, 2012 04:19
app.dynamicHelpers to res.locals

假如模板上要使用 session

before

app.dynamicHelpers({
    session: function (req, res) {
        return req.session;
    }
});
@popomore
popomore / gist:3794407
Created September 27, 2012 14:46
nvm install
curl https://raw.github.com/creationix/nvm/master/nvm.sh -o ~/nvm/nvm.sh && . ~/nvm/nvm.sh
echo ". ~/nvm/nvm.sh" > ~/.bashrc
nvm install v0.8.10
@popomore
popomore / gist:4134264
Created November 23, 2012 06:40
handlebars beta 和 rc 区别

使用 registerHelper 的时候,会提供一个 options,两个版本的接口有变化

Handlebars.registerHelper('link', function(text, options) {
  //
});

beta1

@popomore
popomore / gist:4168947
Created November 29, 2012 13:11
svn ignore

svn 设置忽略

$ svn propset svn:ignore 'a' .

svn 删除忽略

$ svn propdel svn:ignore 'a' .
@popomore
popomore / gist:4176948
Created November 30, 2012 16:53
删除 github 所有的 commit

找到你要回到的 hash

$ git reset --hard hash
$ git push -f origin master
@popomore
popomore / gist:4177159
Created November 30, 2012 17:24
delete submodule
1) .gitmodules
2) .git/config
3) git rm --cache path/to/module