This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Menu = (()=> { | |
'use strict' | |
const addEvent = ( event ) => ( element, action ) => | |
element.addEventListener( event, action(element) ) | |
const addClass = ( _class ) => ( element ) => | |
element.classList.add( _class ); | |
const removeClass = ( _class ) => ( element ) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function curry( fn ) { | |
var arity = fn.length; | |
return (function resolver() { | |
var mem = Array.prototype.slice.call( arguments ); | |
return function() { | |
var args = mem.slice(); | |
Array.prototype.push.apply( args, arguments ); | |
return ( args.length >= arity ? fn : resolver ).apply( null, args ); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var primo = function(n){ | |
if (!isNaN(n)) { | |
if (n != 1) { | |
for (i = 2; i < n; i++) { | |
if(n % i == 0){ | |
return false; | |
} | |
} | |
return n !== 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*eslint-env es6 */ | |
// Inspired by the paper "A tutorial on the universality and | |
// expressiveness of fold" by Graham Hutton ( available at | |
// http://www.cs.nott.ac.uk/~gmh/fold.pdf ), implementing some generic | |
// list handling functions in JavaScript in terms of `fold`. | |
// Personally I had an enlightnening moment when I realised the | |
// beautiful interplay of cons lists and foldr during the FP101x | |
// Haskell course. JavaScript's syntax doesn't make this very apparent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MSG = { | |
dontUpdate: ( usuario ) => ({ | |
mensagem: 'Não foi possível atualizar o usuario ' + usuario.login | |
}), | |
dontInsert: ( usuario ) => ( { | |
mensagem: 'Não foi possível incluir o usuario ' + usuario.login | |
} ), | |
update: ( usuario ) => ( { | |
mensagem: 'Usuario ' + usuario.login + ' atualizada com sucesso', | |
inclusao: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( () => { | |
const getChatTitle = () => document.querySelector('h2.chat-title > span').innerText; | |
const colour = ( WhatsColour ) => { | |
let contains = WhatsColour.colorList.findIndex( c => c.name === WhatsColour.getChatTitle() ); | |
if(contains > -1){ | |
document.querySelector('div#main').style.backgroundColor = WhatsColour.colorList[contains].color; | |
} | |
} | |
const getPerson = (color) => ( { name: getChatTitle(), color } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* imap lazily maps an interable. | |
* @param fn Map function | |
* @param arrOrIterator Either an array or an iterator | |
* | |
* It works by always returning a new iterator so that | |
* you can chain other imaps without loopin once more | |
* over the same array! | |
* | |
* Since iterables are returned, to start the real mapping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
const program = require('commander'); | |
program | |
.version('0.1.5') | |
.usage('[options] <number>') | |
.option('--c2f', 'convert Celsius to Fahrenheit') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CYPHER_LIMIT = 78 | |
const A = 65 | |
const Z = 90 | |
const add = ( c ) => ( s ) => s.concat( c ) | |
const getCharCode = String.fromCharCode | |
const isSpace = ( x ) => ( x === 32 ) | |
const isInRange = ( min, max ) => ( x ) => | |
( ( x >= min ) && ( x <= max ) ) |