Skip to content

Instantly share code, notes, and snippets.

View kutyel's full-sized avatar
🌊
数学者に俺は成る!

Flavio Corpa kutyel

🌊
数学者に俺は成る!
View GitHub Profile
@kutyel
kutyel / facebook.js
Last active October 11, 2020 17:31
Question for my Frontend Interview at Facebook
/*
* Create an event emitter that goes like this
* emitter = new Emitter();
*
* Allows you to subscribe to some event
* sub1 = emitter.subscribe('function_name', callback1);
* (you can have multiple callbacks to the same event)
* sub2 = emitter.subscribe('function_name', callback2);
*
* You can emit the event you want with this api
@kutyel
kutyel / google.js
Created January 14, 2017 16:48
Google's mock interview
/*
* Complete the function below.
*/
function hasPairWithSum(data, sum) {
const comp = new Set();
for (let n of data) {
if (comp.has(n))
return true;
comp.add(sum - n);
}
@kutyel
kutyel / elastic.js
Created January 14, 2017 18:13
Sum of 'Z' numbers in an array
/*
* Complete the function below.
*/
function isSumPossibleZ(numbers, expectedSum, numbersToSum) {
function f(index, expectedSum, numbersToSum) {
if (numbersToSum === 0) return expectedSum === 0;
for (var length = numbers.length; index < length; index++) {
if (f(index + 1, expectedSum - numbers[index], numbersToSum - 1)) {
return 1;
}
@kutyel
kutyel / Lidia.js
Last active February 16, 2017 11:10
Output to the terminal an underground-like message!
#!/usr/bin/env node
const msg = process.argv.slice(2).join(' ').toUpperCase().concat(' '.repeat(20))
let index = -1
setInterval(() => {
index++
process.stdout.write(msg.slice(index).concat(msg.slice(0, index)))
process.stdout.cursorTo(0)
index >= msg.length - 1 && (index = -1)
(function() {
'use strict'
var pressed = []
var KONAMI_CODE = [
'ArrowUp',
'ArrowUp',
'ArrowDown',
'ArrowDown',
'ArrowLeft',
'ArrowRight',
@kutyel
kutyel / carto_help.fish
Created May 19, 2017 12:37
CARTO Development help
function carto_help --description 'CARTO Development help'
echo '+---------------+-----------------+'
echo '| | start_postgres |'
echo '| start_sql_api | start_redis |'
echo '| | start_builder |'
echo '+---------------+-----------------+'
echo '| | |'
echo '| start_tiler | start_resque |'
echo '| | |'
echo '+---------------+-----------------+'
@kutyel
kutyel / webpack.config.babel.js
Created June 13, 2017 08:21
Webpack 2 with React, CSS Modules & SASS
import webpack from 'webpack';
import { resolve } from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import ForceCaseSensitivityPlugin from 'force-case-sensitivity-webpack-plugin';
import autoprefixer from 'autoprefixer';
import getClientEnvironment from './config/env';
const nodeModulesPath = resolve(__dirname, 'node_modules');
const bowerModulesPath = resolve(__dirname, 'bower_components');
const srcPath = resolve(__dirname, 'src');
@kutyel
kutyel / debounce-es2015.js
Last active June 14, 2017 12:14 — forked from vincentorback/debounce-es2015.js
Smarter debouncing
export function debounce(fn, wait = 200) {
let timeout;
return function (...args) {
clearTimeout(timeout);
timeout = setTimeout(() => fn.call(this, ...args), wait);
}
}
@kutyel
kutyel / toBadger.js
Last active June 30, 2017 10:22
Translate to badger language using native JavaScript functional programming (without Ramda.js)
/**
* Translate a sentence to badger language,
* applying the following transformations:
*
* 1) Reverse letters
* 2) Capitalize first letter
* 3) Reverse words
*
* Sample input: "Thank you"
* Sample output: "Uoy Knaht"