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
var SpecHelper = {}; | |
var _flags = { | |
didRun: {} | |
}; | |
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
// Requires the `qs` package | |
var qs = require('qs'); | |
var path = require('path'); | |
var url = require('url'); | |
module.exports = (helpers) => { | |
helpers.registerDirectory('url/', (helper) => { | |
Object.keys(helper).forEach((key) => { |
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
[ | |
{ "name": "Alabama" }, | |
{ "name": "Alaska" }, | |
{ "name": "Arizona" }, | |
{ "name": "Arkansas" }, | |
{ "name": "California" }, | |
{ "name": "Colorado" }, | |
{ "name": "Connecticut" }, | |
{ "name": "Delaware" }, | |
{ "name": "Florida" }, |
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
// Pagination algorithm | |
// Refactored by https://github.com/BideoWego | |
// Originally from: | |
// https://gist.github.com/kottenator/9d936eb3e4e3c3e02598 | |
function pagination(current, max, delta) { | |
// Return nada if we got | |
// no pages |
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 _ = require('lodash'); | |
function _createPages(current, max, delta) { | |
// Return nada if we got | |
// no pages | |
if (!max) { | |
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
{ | |
"keys": ["tab"], | |
"command": "expand_abbreviation_by_tab", | |
// put comma-separated syntax selectors for which | |
// you want to expandEmmet abbreviations into "operand" key | |
// instead of SCOPE_SELECTOR. | |
// Examples: source.js, text.html - source | |
"context": [ | |
{ |
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
/* | |
String Permutations Tree | |
Devise a class that when instantiated it create a tree that maps out all of the possible permutations of a given string. | |
- The root node will have a value of `undefined` | |
- The direct children of the root node will be each char of the string | |
- This pattern will continue until it maps out each unique permutation of the string |
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 fn = num => ( | |
num >= 0 && num < 10 ? '1-9' : | |
num >= 10 && num < 20 ? '10-19' : | |
num >= 20 && num < 30 ? '20-29' : | |
num >= 30 && num < 40 ? '30-39' : | |
num >= 40 && num < 50 ? '40-49' : | |
num >= 50 && num < 60 ? '50-59' : | |
num >= 60 && num < 70 ? '60-69' : | |
num >= 70 && num < 80 ? '70-79' : | |
num >= 80 && num < 90 ? '80-89' : |
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
/* | |
Modified from this SO post: | |
https://stackoverflow.com/questions/24069344/split-spaces-avoiding-double-quoted-js-strings-from-a-b-c-d-to-a | |
*/ | |
/('|")(?:\\('|")|\\\\|[^'|"])*('|")|\S+/ | |
"a b 'c d'".match(/('|")(?:\\('|")|\\\\|[^'|"])*('|")|\S+/g) | |
//=> [ 'a', 'b', '\'c d\'' ] |
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 randomDate(start, end) { | |
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime())); | |
} | |
console.log(randomDate(new Date(2012, 0, 1), new Date())); |