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
class Node { | |
constructor(value, left = null, right = null) { | |
this.value = value; | |
this.left = left; | |
this.right = right; | |
} | |
} | |
class BinarySearchTree { | |
constructor() { |
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
/** | |
* Execute an array of async functions in series | |
*/ | |
const sequential = async fns => { | |
const AsyncFunction = (async () => {}).constructor | |
// Use "some" rather than "every" here to abort faster | |
if (!fns.some(fn => fn instanceof AsyncFunction)) { | |
throw new TypeError('`fns` argument should be an array of Async functions') | |
} |
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
{ | |
"[javascript]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
} | |
} |
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
time_namelookup: %{time_namelookup}\n | |
time_connect: %{time_connect}\n | |
time_appconnect: %{time_appconnect}\n | |
time_pretransfer: %{time_pretransfer}\n | |
time_redirect: %{time_redirect}\n | |
time_starttransfer: %{time_starttransfer}\n | |
----------\n | |
time_total: %{time_total}\n |
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
/** | |
* Create custom response | |
* @param {Object} res - express response object | |
* @param {Number} status - status code | |
* @param {String} defaultMessage - default response | |
* @returns {Function} returns function which access response message | |
*/ | |
const createResponse = (res, status, defaultMessage) => data => { | |
// Set status code | |
res.status(status) |
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
# 'cat' after first line | |
cat {filename} | tail -n+2 | |
# (CSV) Get every value of first column (separated by comma) | |
cat {filename} | awk -F',' '{printf $1","}' | |
# (CSV) Get every value of first column (one per line) | |
cat {filename} | awk -F',' '{print $1}' | |
# Only print first x lines (4 in this case) |
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
// Tell "now" to look for a now-secrets.json file | |
// (where we'll store our local secrets - NOT production secrets) | |
require('now-env') | |
const path = require('path') | |
const express = require('express') | |
const session = require('express-session') | |
const bodyParser = require('body-parser') | |
const morgan = require('morgan') // optional | |
const passport = require('passport') |
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
{ | |
"name": "app-name", | |
"alias": "app-name.now.sh" | |
} |
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, { Component } from 'react' | |
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom' | |
import FirebaseProvider, { Consumer as FirebaseConsumer } from './FirebaseProvider' | |
class Container extends Component { | |
render() { | |
return ( | |
<Router> | |
<FirebaseProvider> | |
<FirebaseConsumer> |
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
/** | |
* Lookup an object property by dot notation | |
* @param {Object} obj - object to perform lookup | |
* @param {String} key - property location | |
* @param {Any} fallback - fallback if not found | |
* @return {Any} returns value of lookup if found, otherwise undefined | |
*/ | |
const get = (obj, key, fallback) => | |
key | |
.split('.') |