Skip to content

Instantly share code, notes, and snippets.

View elrrrrrrr's full-sized avatar
🐼
Hope it was happy

elrrrrrrr elrrrrrrr

🐼
Hope it was happy
  • alipay.com
  • Shanghai
View GitHub Profile
@elrrrrrrr
elrrrrrrr / tinytutor
Created December 31, 2014 16:41
tiny VIMtutor
# Tiny VIM tutor .
## 移动光标
* `hjkl` -> 左下上右
## 重复
* `number command object` -> 重复
@elrrrrrrr
elrrrrrrr / gist:bdabf51a8cc2f995ca5e
Created December 18, 2014 16:09
simple-promise
var Promise = function (fun) {
var me = this,
resolve = function (val) {
me.resolve(val);
},
reject = function (val) {
me.reject(val);
}
me._st = 'pending';
me._rsq = null;
@elrrrrrrr
elrrrrrrr / change author
Last active August 29, 2015 14:10
git commit
//修改提交过的commit author 例如提交纪录 A-B-C-D-E 修改C D author
//rebase至 前一个commit 即B
git rebase -i B
//将B和C的action写成eidt或者e
//rebase会执行至C,所以可以修改C的author
git commit --amend --author="Author Name <email address>"
git rebase --continue
//接着就会执行到D
git commit --amend --author="Author Name <email address>"
@elrrrrrrr
elrrrrrrr / 延迟计算
Created November 22, 2014 11:35
柯里化
//
//简单累加全局变量
var fishWeight = 0;
var addWeight = function(weight) {
fishWeight += weight;
};
addWeight(2.3);
addWeight(6.5);
addWeight(1.2);
addWeight(2.5);
@elrrrrrrr
elrrrrrrr / simple-co
Created November 21, 2014 04:22
simple-co
function co(generator) {
return function(fn) {
var gen = generator();
function next(err, result) {
if(err){
return fn(err);
}
var step = gen.next(result);
if (!step.done) {
@elrrrrrrr
elrrrrrrr / raphael
Created November 13, 2014 12:02
SVG-circle-image
var circle = paper.circle(size/4, size/4, 40);
var uuid = Raphael.createUUID();
var pattern = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
var backgroundImage = paper.image("../css/tx.png", 0, 0, 1, 1);
pattern.setAttribute("id", uuid);
pattern.setAttribute("x", 0);
pattern.setAttribute("y", 0);
pattern.setAttribute("height", 1);
pattern.setAttribute("width", 1);
pattern.setAttribute("patternContentUnits", "objectBoundingBox");
@elrrrrrrr
elrrrrrrr / github.css
Last active August 29, 2015 14:08 — forked from tuzz/github.css
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px;
color: #333;
}
@elrrrrrrr
elrrrrrrr / nodeInhrits
Created October 11, 2014 07:08
node 继承标准写法
function Socket(options) {
// ...
stream.Stream.call(this);
// ...
}
util.inherits(Socket, stream.Stream);
@elrrrrrrr
elrrrrrrr / gulpfile.js
Created September 25, 2014 13:23
css sprites
var gulp = require('gulp');
var gulpif = require('gulp-if');
var sprite = require('css-sprite').stream;
var base = require('gulp-base64');
// generate sprite.png and _sprite.scss
gulp.task('sprites', function () {
return gulp.src('img/*.png')
.pipe(sprite({
name: 'tx.png',
@elrrrrrrr
elrrrrrrr / gulpfile.js
Created September 18, 2014 14:20
common gulpfile.js
var gulp = require('gulp'),
stylus = require('gulp-stylus'),
jade = require('gulp-jade');
jademod = require('jade2mod');
var paths = {
stylus: ['stylus/*.styl'],
html: ['html/*.html'],
jade: ['jade/*.jade'],
engine: ['jade/engine/*.jade']