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
'use strict';
const jscodeshift = require('jscodeshift');
const { MemberExpression, Property } = jscodeshift;
jscodeshift.registerMethods({
// exports.a => exports.b
//
// jscodeshift(source)
// .find(jscodeshift.Identifier, { name: 'a' })
@popomore
popomore / labels.json
Created May 26, 2016 05:40
labels.json
[{
"name": "milestone",
"color": "0052cc"
}, {
"name": "task",
"color": "009800"
}, {
"name": "feature",
"color": "009800"
}, {
@popomore
popomore / gist:10986324
Last active August 29, 2015 13:59
输出是乱码
var urllib = require('urllib');
// 乱码
urllib.request('http://static.alipayobjects.com/build/js/arale.js', {}, function (err, data, res) {
console.log(data.toString());
});
// 正常
urllib.request('https://a.alipayobjects.com/build/js/arale.js', {}, function (err, data, res) {
console.log(data.toString());
@popomore
popomore / ast-parsed-by-esprima.js
Created February 27, 2014 08:36
Ast node type parsed by esprima, install esprima first
var esprima = require('esprima');
var code = [];
// Literal
code.push('1;');
code.push('true;');
code.push('"a";');
code.push('/a/g;');
code.push('null;');
var bench = require('bench');
var compare = {};
var data = {};
// 先安装 bench
// 10^5 基本小于 1 ms,所以对比 10^5 到 10^6 之间的数
for (var i = 1; i <= 10; i++) {
var count = 100000 * i;
(function(count) {
var content = createContent(count);
# install gist by `brew install gist`
#
# create gist on first time
# update gist when .gistid exists
function gist() {
local gistid
args=$@
if [ -f .gistid ]; then
gistid=$(cat .gistid)
@popomore
popomore / README.md
Last active January 2, 2016 11:19
alfred cdn
@popomore
popomore / uniq.js
Created November 27, 2013 11:45
数组去重
Array.prototype.uniq = function() {
return this.filter(function(item, index, arr) {
return index === arr.indexOf(item);
});
};
// test
[1,2,3,2,1,2,4,6,8,3,2].uniq();
function readDirs(dir) {
var result = [];
fs.readdirSync(dir)
.forEach(function(file) {
var sub = path.join(dir, file);
if (fs.statSync(sub).isDirectory()) {
result = result.concat(readDirs(sub).map(function(subFile) {
return path.join(file, subFile);
}));
} else {