start new:
tmux
start new with session name:
tmux new -s myname
let slice = Array.prototype.slice; | |
let str = s => slice.call(s) | |
let unstr = cs => cs.reduce((c, cs) => c + cs, "") | |
let concat = xss => xss.reduce((xs, ys) => xs.concat(ys), []) | |
let id = x => x | |
let negate = x => -x | |
let add = (x,y) => x + y | |
let sub = (x,y) => x - y | |
// type Parser a = () -> [Char] -> a |
/*eslint-disable no-console, radix*/ | |
import webpack from 'webpack'; | |
import path from 'path'; | |
import writeStats from './writeStats'; | |
import ExtractTextPlugin from 'extract-text-webpack-plugin'; | |
import CleanPlugin from 'clean-webpack-plugin'; | |
import autoprefixer from 'autoprefixer-core'; | |
import webpackStripLoader from 'strip-loader'; | |
import { host, webpackPort, buildDir } from '../config'; |
import * as NotificationAction from 'actions/NotificationActions' | |
импортов может и не быть, если мы в обработчике нативно обрабатываем запросы | |
export default function 404({ status, statusText }, dispatch, getState) { | |
if (status === 404) { | |
dispatch(NotificationAction.send({message: statusText})) | |
} | |
} | |
Таких файлов будет ровно столько сколько будет обработчиков |
typeof NaN == 'number'; | |
42 == [[[[[[[42]]]]]]]; | |
'foo' > 'bar'; | |
NaN != NaN; | |
null >= 0 // true, т.к. null преобразуется к 0 | |
null > 0 // false т.к. null преобразуется к 0 | |
null == 0 // false | |
5 - '3' === 2 |
/* jshint esnext:true */ | |
/** | |
* "Producer-Consumer" implementation using generators. | |
* @see http://en.wikipedia.org/wiki/Deterministic_concurrency#Comparison_with_generators | |
*/ | |
var SIZE = 3, | |
queue = newQueue(); |
// array utils | |
// ================================================================================================= | |
const combine = (...arrays) => [].concat(...arrays); | |
const compact = arr => arr.filter(Boolean); | |
const contains = (() => Array.prototype.includes | |
? (arr, value) => arr.includes(value) | |
: (arr, value) => arr.some(el => el === value) |
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
/* jshint esnext:true */ | |
// native generators | |
function* random() { | |
var i = 0; | |
while(i++ < 1e5) { | |
yield Math.random(); | |
} | |
} |
const loop = (() => { | |
const recur = (callback, count, i=0) => { | |
if (i == count-1) return callback(i); | |
callback(i); | |
return recur(callback, count, i+1); | |
}; | |
return (callback, count) => { | |
if (count > 0) return recur(callback, count); | |
}; | |
})(); |