start new:
tmux
start new with session name:
tmux new -s myname
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'); |
var schedule = (function (self) { | |
var paused = false, // 标记状态 | |
queue = []; // 队列 | |
// 入队 | |
self.join = function (fn, params) { | |
params = params || {}; | |
var args = [].concat(params.args); | |
queue.push(function (_) { |
;(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; | |
}, []) |
;(function (window, undefined) { | |
var _slice = Array.prototype.slice; | |
function variadic(fn) { | |
var numParams = fn.length, // 形参个数 | |
numNamedArgs = numParams - 1; | |
return numParams < 1 ? fn : function () { | |
var |
;(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)); |
// closure caveat | |
// case 1 | |
;(function (window, $, undefined) { | |
var $target; | |
function howdy() { | |
var x = 'foo'; | |
if (!$target) { |
Every time I start a new project, I want to pull in a log
function that allows the same functionality as the console.log
, including the full functionality of the Console API.
There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log
was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.
This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:
_.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]; |