Skip to content

Instantly share code, notes, and snippets.

View suissa's full-sized avatar
🏠
Working from home

Jean Carlo Nascimento suissa

🏠
Working from home
  • Suissa Corp
  • Brasil
View GitHub Profile
@suissa
suissa / header.js
Last active September 16, 2017 04:20 — forked from tosipaulo/header.js
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 ) =>
@suissa
suissa / curry.js
Created August 14, 2017 23:16 — forked from kevincennis/curry.js
curry.js
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 );
};
@suissa
suissa / primo.odiegoprado.js
Last active July 12, 2017 13:12
Verificando número primo
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;
}
@suissa
suissa / fold.js
Last active July 11, 2017 19:34 — forked from jbmusso/fold.js
Functional acrobatics using folds in JavaScript.
/*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
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
@suissa
suissa / whatscolour.js
Last active June 23, 2017 23:22
WhatsColour is a background coloring for Whatsapp Web
( () => {
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 } );
@suissa
suissa / imap.js
Created June 23, 2017 19:30 — forked from lubien/imap.js
Proof of concept that you can map multiple functions with only one iteration in JavaScript using iterators (like in Python). Run https://repl.it/Izou/0
/*
* 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
@suissa
suissa / thermoCLI.js
Last active March 16, 2019 19:54
Source Code from ThermoCLI - refatorado by Suissinha
#!/usr/bin/env node
'use strict';
const program = require('commander');
program
.version('0.1.5')
.usage('[options] <number>')
.option('--c2f', 'convert Celsius to Fahrenheit')
@suissa
suissa / primeNumberCheck.js
Last active June 17, 2017 04:54 — forked from Woodsphreaker/primeNumberCheck.js
Prime Number Check
// Eu faria assim porém essa lógica ESTA ERRADA!!!!
const generateSequenceFromOneUntil = ( max ) =>
[ ...Array(max).keys() ].slice(1)
const isLowerThan = ( divisors ) => ( number ) =>
( number > Math.max( ...divisors ) )
const mergeInArray = ( x, y ) => [].concat( x,y )
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 ) )