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 / download.js
Created July 29, 2013 13:59
simple download
var fs = require('fs');
var path = require('path');
var url = require('url');
var protocol = {
https: require('https'),
http: require('http')
};
function download(src, dest, cb) {
var options = url.parse(src);
@popomore
popomore / Gruntfile.js
Last active December 20, 2015 07:39
Gruntfile 的一些配置
module.exports = function(grunt) {
grunt.initConfig({
// https://github.com/gruntjs/grunt-contrib-watch
// grunt.loadNpmTasks('grunt-contrib-watch');
// 页面上插入 <script src="http://localhost:35729/livereload.js"></script>
watch: {
scripts: {
files: ['**/*'],
task: [],
@popomore
popomore / format.js
Created July 27, 2013 14:40
string format
function format(fmt, args) {
if (!fmt) return '';
var toString = Object.prototype.toString;
if (toString.call(args) === '[object Object]') {
return fmt.replace(/%{?([a-z]*)}?/g, function(all, m1){
return args[m1] ? args[m1] : all;
});
} else {
if (toString.call(args) !== '[object Array]') {
@popomore
popomore / redirect.js
Created May 28, 2013 16:29
shell redirect in nodejs
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
function run(cmd) {
var output, out, index = cmd.indexOf('>');
if (index > -1) {
output = cmd.substring(index + 1).replace(/(^\s+|\s+$)/g, '');
cmd = cmd.substring(0, index).split(/\s+/);
} else {
var https = require('https');
var Base64 = require('js-base64').Base64; // can use other base64 implement
var twitterConsumerKey = 'your consumer key';
var twitterConsumerSecret = 'your consumer secret';
var encodedBearerToken = Base64.encode(twitterConsumerKey + ':' + twitterConsumerSecret);
var options = {
hostname: 'api.twitter.com',
path: '/oauth2/token',
@popomore
popomore / gist:5585736
Created May 15, 2013 17:31
nodejs 文件权限转换
var stat = fs.statSync(dir);
(stat.mode & 07777).toString(8); // => e.g. 755
@popomore
popomore / gist:4177159
Created November 30, 2012 17:24
delete submodule
1) .gitmodules
2) .git/config
3) git rm --cache path/to/module
@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:4168947
Created November 29, 2012 13:11
svn ignore

svn 设置忽略

$ svn propset svn:ignore 'a' .

svn 删除忽略

$ svn propdel svn:ignore 'a' .
@popomore
popomore / gist:4134264
Created November 23, 2012 06:40
handlebars beta 和 rc 区别

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

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

beta1