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
/* | |
* 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 |
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
/* | |
* 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); | |
} |
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
/* | |
* 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; | |
} |
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 | |
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) |
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() { | |
'use strict' | |
var pressed = [] | |
var KONAMI_CODE = [ | |
'ArrowUp', | |
'ArrowUp', | |
'ArrowDown', | |
'ArrowDown', | |
'ArrowLeft', | |
'ArrowRight', |
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
license: mit |
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 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 '+---------------+-----------------+' |
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
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'); |
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
export function debounce(fn, wait = 200) { | |
let timeout; | |
return function (...args) { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => fn.call(this, ...args), wait); | |
} | |
} |
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
/** | |
* 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" |