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 / 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: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: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: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: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 / 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"]