Skip to content

Instantly share code, notes, and snippets.

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@redbluish
redbluish / closure_caveat.js
Created December 9, 2013 12:46
closure_caveat.js
// closure caveat
// case 1
;(function (window, $, undefined) {
var $target;
function howdy() {
var x = 'foo';
if (!$target) {
@redbluish
redbluish / curry.js
Created December 6, 2013 16:12
curry.js
;(function (window, undefined) {
var _slice = [].slice;
function curry(fn) {
var arity = fn.length;
return (function given(argsSoFar) {
return function () {
var updatedArgsSoFar = argsSoFar.concat(_slice.call(arguments, 0));
@redbluish
redbluish / variadic.js
Created December 1, 2013 17:09
variadic.js
;(function (window, undefined) {
var _slice = Array.prototype.slice;
function variadic(fn) {
var numParams = fn.length, // 形参个数
numNamedArgs = numParams - 1;
return numParams < 1 ? fn : function () {
var
@redbluish
redbluish / df.js
Created November 27, 2013 08:59
dynamic generate methods.
;(function (window, undefined) {
// [es5-shim.min.js](http://tinyurl.com/omk7rjt)
'use strict';
'11||111||2||2||3||4||2||3||3||4||5||5||3||4||5||6||5||6||4||4||4||4||4||4||4||4||4||5||6||6'
.split('||')
.reduce(function (result, item, index) {
index % 6 === 0 ? result.push([item]) : result[result.length - 1].push(item);
return result;
}, [])
@redbluish
redbluish / schedule.js
Created November 17, 2013 02:04
schedule.js
var schedule = (function (self) {
var paused = false, // 标记状态
queue = []; // 队列
// 入队
self.join = function (fn, params) {
params = params || {};
var args = [].concat(params.args);
queue.push(function (_) {
@redbluish
redbluish / String#succ_prec.js
Created November 17, 2013 01:29
String#succ_prec.js
String.prototype.succ = function () {
if (!/^[a-z]+$/.test(this)) return '';
var parts = this.split(''),
i = parts.length - 1;
do {
parts[i] = String.fromCharCode(97 + (parts[i].charCodeAt(0) - 70) % 26);
if (parts[i] !== 'a') break;
else if (i === 0) parts.unshift('a');
@redbluish
redbluish / webcommon.js
Created April 2, 2014 03:03
异步顺序加载JS脚本
var WebCommon = (function (func) {
return func(WebCommon || {}, $);
}).call(this, function (wc, $, undefined) {
var
// 获取指定param的查询字符串值
query = function (param) {
var match = RegExp('[?&]' + param + '=([^&]*)').exec(location.href.split('#')[0]);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
},
@redbluish
redbluish / jquery-map-pitfall.js
Created April 2, 2014 03:01
jQuery.map的坑
_.map(['foo', 'bar'], function (item, index) {
return [index, item];
});
['foo', 'bar'].map(function (item, index) {
return [index, item];
});
$(['foo', 'bar']).map(function (index, item) {
return [index, item];