Consider the following scenario
function invert(color) {
var lookup = {
black: 'white',
white: 'black'
}
// Another useful reducer | |
// | |
// Get unique values of a 1d array | |
function unique (a, b) { | |
if (a.indexOf(b) < 0) a.push(b) | |
return a | |
} | |
// Very simple use case | |
var arr = [1, 5, 7, 2, 2, 3, 3, 4, 5, 5, 52, 4, 1, 2, 9, 1, 3, 5] |
// Y-combinator with memoization | |
var Yc = function (f, x) { | |
x = x || {}; | |
return function () { | |
var y = JSON.stringify([].slice.call(arguments)); | |
return x[y] || (x[y] = f(function (z) { | |
return Yc(f, x)(z); | |
}).apply(this, arguments)); |
{ | |
"cmd": ["/usr/local/bin/node", "$file"], | |
"selector": "*.js" | |
} |
var fs = require('fs'); | |
var rfs = fs.readFileSync; | |
var wfs = fs.writeFileSync; | |
var path = require('path'); | |
var yaml = require('js-yaml'); | |
var inquirer = require('inquirer'); | |
var program = require('commander'); | |
var version = require('./package.json').version; | |
program |
from Crypto.Cipher import AES | |
from Crypto import Random | |
from libmproxy.flow import decoded | |
BS = 16 | |
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS) | |
unpad = lambda s : s[0:-ord(s[-1])] | |
def decrypt( enc, key ): | |
iv = enc[:16] |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
{ | |
"cmd": ["/usr/local/bin/babel-node $file"], | |
"shell": true, | |
"selector": "*.js" | |
} |
Inspired by Haskell, I wanted to see if I could replicate, using ES6 features, the repeat
function:
repeat :: a -> [a]
So as you can see in repeat.js
, I have done exactly that. However there are some caveats.
Automate your developer workflow with git-guppy. git-guppy allows you to add git-hooks to your project repository that are automatically installed when users clone and install your repository, so you won't have to worry about developers skipping essential workflow steps and bypassing your project guidelines.
So let's use a unit test scenario to illustrate an example. We're going to run unit tests before every commit (pre-commit hook) and reject the commit if the tests fail (giving the developer a chance to fix their tests before committing broken code).