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 handlebars = require("handlebars"); | |
const operators = { | |
"+": (a, b) => a + b, | |
"-": (a, b) => a - b, | |
"*": (a, b) => a * b, | |
"/": (a, b) => a / b, | |
"%": (a, b) => a % b | |
}; | |
handlebars.registerHelper("math", function (a, op, b) { |
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
// Based on https://codepen.io/somethingkindawierd/post/react-mixin-scroll-lock | |
// How this works is that it will lock the scroll of the component parents | |
// and allow the current element to scroll | |
import ReactDOM from "react-dom"; | |
const ScrollLockMixin = { | |
scrollLock: function (scrollElement) { | |
let p; | |
this.scrollElement = scrollElement || ReactDOM.findDOMNode(this); |
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 getCreditCardIssuer(number) { | |
number = number.toString(); | |
if (/^4[0-9]{12}(?:[0-9]{3})?$/.test(number)) { // Visa | |
return { | |
issuer : 'Visa', | |
cidLength : 3, | |
length : 16 | |
}; | |
} else if (/^5[1-5][0-9]{14}$/.test(number)) { // MasterCard | |
return { |
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
interface ILib { | |
alpha: string[], | |
number: string[], | |
symbols: string[] | |
} | |
type Key = keyof ILib; | |
const lib : ILib = { | |
alpha: [ |
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
Show hidden characters
{ | |
"presets": [], | |
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs"] | |
} |
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
module.exports = function promisify(fn) { | |
const args = []; | |
for (var i = 1, n = arguments.length; i < n; i++) { | |
args.push(arguments[i]); | |
} | |
return new Promise(function (resolve, reject) { | |
args.push(function (err) { | |
const 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
function getUsStates(number) { | |
var states = [ | |
'Alabama', | |
'Alaska', | |
'American Samoa', | |
'Arizona', | |
'Arkansas', | |
'California', | |
'Colorado', | |
'Connecticut', |
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 hasKey (object, key) { | |
for (var k in object) { | |
if (k === key && object.hasOwnProperty(key)) { | |
return true; | |
} | |
} | |
return 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
function partial(fn) { | |
var left = new Array(arguments.length - 1); | |
var leftIndex = 0; | |
for (; leftIndex < left.length; leftIndex++) { | |
left[leftIndex] = arguments[leftIndex + 1]; | |
} | |
return function () { | |
var right = new Array(arguments.length); |
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 () { | |
var lib = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
var n = lib.length - 1; | |
function generateId(index) { | |
var id = []; | |
while (index-- > 0) { | |
id.push(lib[Math.round(Math.random() * n)]); | |
} | |
return id.join(''); |
NewerOlder