This file contains hidden or 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
/** | |
* getChangeInCoins | |
* @description given money and price it would return coins as [1c, 5c, 10c, 25c, $1] | |
* @param {float} money | |
* @param {float} price | |
*/ | |
const getChangeInCoins = (money, price) => { | |
let value = (money - price) * 100; | |
return [100, 25, 10, 5, 1] | |
.map((coin) => { |
This file contains hidden or 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 missingInteger = (A) => { | |
// remove dups and filter by integers | |
A = Array.from(new Set(A)).filter((i) => i > 0); | |
if (!A.length) return 1; | |
const max = Math.max.apply(Math, A); | |
const items = new Array(max); | |
A.forEach((x) => (items[x - 1] = x)); |
This file contains hidden or 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 React from 'react'; | |
import { shallow } from 'enzyme'; | |
import Button from './Button'; | |
let props; | |
beforeEach(() => { | |
props = { | |
isPrimary: false, | |
isDanger: false, |
This file contains hidden or 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
// String utils | |
// | |
// resources: | |
// -- mout, https://github.com/mout/mout/tree/master/src/string | |
/** | |
* "Safer" String.toLowerCase() | |
*/ | |
function lowerCase(str){ | |
return str.toLowerCase(); |
This file contains hidden or 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 removeAccents(string) { | |
const special = 'ÀÁÂÃÄÅĄàáâãäåąßÒÓÔÕÕÖØÓòóôõöøóÈÉÊËĘèéêëęðÇĆçćÐÌÍÎÏìíîïÙÚÛÜùúûüÑŃñńŠŚšśŸÿýŽŻŹžżź'; | |
const stripped = 'AAAAAAAaaaaaaaBOOOOOOOOoooooooEEEEEeeeeeeCCccDIIIIiiiiUUUUuuuuNNnnSSssYyyZZZzzz'; | |
return string | |
.split('') | |
.map((letter) => { | |
const index = special.indexOf(letter); | |
return index !== -1 ? stripped[index] : letter; |
This file contains hidden or 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 bingen(size) { | |
let c; | |
return Array.from({length: size}, (y, k) => c = (c||1) * 2); | |
} |
This file contains hidden or 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 | |
// Save hook under `project-root/hooks/before_prepare/` | |
// | |
// Don't forget to install xml2js using npm | |
// `$ npm install xml2js` | |
var fs = require('fs'); | |
var xml2js = require('xml2js'); |
This file contains hidden or 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 Stack = (function(){ | |
'use strict'; | |
// Class private shared vars | |
var place = 'kitchen'; | |
// Constructor | |
function Stack(some){ | |
// Instance private vars |
This file contains hidden or 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 FIFO = (function () { | |
'use strict'; | |
// Load Dependencies | |
var _ = require('lodash'); | |
// Set default configurations | |
var defaultConfig = { | |
type: 'number', | |
random: false, |
This file contains hidden or 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 step = 1, | |
active = 0, | |
items = new Array(); | |
function next(){ | |
active = (active + step) % items.length; | |
// active = ++active % items.length; | |
} | |
function prev(){ |