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
require('dotenv').config() | |
const { HOST, PORT } = process.env | |
const request = require('supertest')(`http://${HOST}:${PORT}`) | |
describe('Users CRUD APIs', () => { | |
let userId // gets stored once we create a user | |
const userInfo = { | |
name: 'Dade Murphy', | |
username: 'Zero Cool', | |
address: { |
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
getDuration (duration) { // duration in ms | |
const timeString = new Date(duration).toISOString().substr(11, 8) | |
const time = _.reduce(timeString.split(':'), (result, piece, index) => { | |
let key | |
if (index === 0) key = 'hours' | |
if (index === 1) key = 'minutes' | |
if (index === 2) key = 'seconds' | |
result[key] = parseInt(piece, 10) | |
return result | |
}, {}) |
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
version: '3.3' | |
services: | |
db: | |
image: mysql:5.7 | |
volumes: | |
- db_data:/var/lib/mysql | |
ports: | |
- 3306 | |
networks: | |
- blogosphere |
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
// -------------------------------------------- SERVER SIDE | |
const base64 = require('base64-url') | |
const crypto = require('crypto') | |
const moment = require('moment') | |
function calculatePolicy(policy, secret) { | |
const policyString = JSON.stringify(policy) | |
const encodedPolicy = base64.encode(policyString) | |
const signature = crypto.createHmac('sha256', secret).update(secret).digest('hex') |
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 konamiCode = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13] | |
let konamiTracker = [] | |
const listener = event => { | |
const key = event.keyCode | |
const currentSequence = [...konamiTracker, key] | |
const slice = konamiCode.slice(0, currentSequence.length) | |
const isPartialMatch = _.isEqual(currentSequence, slice) | |
const isExactMatch = _.isEqual(currentSequence, konamiCode) |
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
// Place your settings in this file to overwrite the default settings | |
{ | |
"editor.tabSize": 2, | |
"editor.fontFamily": "Operator Mono, Inconsolata, Hack, Input Mono Narrow, Consolas, Input Mono, Menlo, Monaco", | |
"editor.fontSize": 12, | |
"editor.fontWeight": "300", | |
"editor.wordWrap": "on", | |
"terminal.external.osxExec": "Terminal.app", | |
"search.exclude": { | |
"**/node_modules": true, |
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') | |
const path = require('path') | |
const webpack = require('webpack') | |
const ExtractTextPlugin = require('extract-text-webpack-plugin') | |
const pkg = require('./package.json') | |
// Webpack: The Confusing Parts | |
// https://medium.com/@rajaraodv/webpack-the-confusing-parts-58712f8fcad9 | |
const isDevelopment = process.env.NODE_ENV === 'development' |
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 babel-node | |
var _ = require('lodash') | |
var exec = require('child_process').exec | |
var onDockerStopContainer = function (err, stdout, stderr) { | |
if (err) { | |
return console.error(err) | |
} |
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 _ = require('lodash') | |
var exec = require('child_process').exec | |
var removeUnnamedDockerImages = function (json) { | |
_.forEach(json, function (image) { | |
if (image.repo === '<none>') { | |
exec('docker rmi -f ' + image.imageId, function (rmErr, rmStdout, rmStderr) { | |
if (rmErr) { | |
return console.error(rmErr) | |
} |
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 express = require('express') | |
var router = express.Router() | |
var qs = require('qs') | |
function login (req, res) { | |
const query = qs.parse(req.query) | |
req.session.alexa = query // store the variables for the redirect URI after successful login | |
res.render('login') | |
} |