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 _ = require('lodash') | |
const IRRELEVANT_PROPS_FOR_OBJECT_COMPARISON = ['__v', '_doc', '$__', '_id']; | |
/* | |
* Remove properties that you don't care about from a mongoose object | |
* to make comparing mongoose objects easy. | |
*/ | |
omitIrrelevantMongoosePropertiesForObjComparison(obj) { | |
let relevantObjProps; |
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 _ = require('moment') | |
const MAX_MONTHS_TO_TEST_DST_OFFSET = 12; | |
const convertToMoment = (date) { | |
if (date instanceof moment) return date; | |
return new moment(date); | |
} | |
const wasDSTNowNot = (was, now = new moment()) => { |
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
/* | |
* Given the following schema for collection 'foo': | |
* myDoc: { | |
* embeddedDocs: [ | |
* { | |
* bar: 'a', | |
* baz: 'b', | |
* }, | |
* { | |
* bar: 'b', |
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
// Terminal | |
npm init | |
npm install --save babel-cli babel-preset-env | |
// Visual Studio Code | |
// Tasks --> Configure Tasks | |
// tasks.json | |
{ | |
"version": "0.1.0", | |
"command": "${workspaceRoot}/node_modules/.bin/babel-node", |
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 hashids | |
SALT = "this is my salt" | |
hash_func = hashids.Hashids(salt=SALT, min_length=16) | |
hash_ = hash_func.encode(1,) # ''JEDngB0NV05ev1Ww' | |
ids = hash_func.decode(hash_) # (1,) |
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
# Install packages to allow Node to be installed | |
sudo apt-get update | |
sudo apt-get install software-properties-common | |
sudo apt-get install apt-transport-https | |
# Install Node | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 68576280 | |
# change /node_6.x to whatever release version of node you would like (e.g. node_5.x) | |
sudo apt-add-repository "deb https://deb.nodesource.com/node_6.x $(lsb_release -sc) main" |