Skip to content

Instantly share code, notes, and snippets.

View rg1220's full-sized avatar

Randy rg1220

View GitHub Profile
@rg1220
rg1220 / keybase.md
Created April 30, 2018 15:56
keybase.md

Keybase proof

I hereby claim:

  • I am rg1220 on github.
  • I am rg1220 (https://keybase.io/rg1220) on keybase.
  • I have a public key ASC2TiWrFpbyn1difOPAOcV3m67k8XmIVhVB4NFU0D6rMwo

To claim this, I am signing this object:

@rg1220
rg1220 / flatten.js
Created April 3, 2018 18:35
Flatten Array
/**
* Recursive function to flatten the current array level
* @param {Array<any>} arr - The array to flatten
* @returns {Array<any>} New flattened array
*/
const flatten = (arr) => {
const newArray = [];
arr.forEach((item) => {
if (Array.isArray(item)) {
newArray.push(...flatten(item));
@rg1220
rg1220 / api.js
Last active April 9, 2019 06:38
Here's a simple gist for getting a user before another route handles the actual command.
var express = require('express');
var router = express.Router();
router.use(function (req, res, next) {
User.findOne(1234, function(err, user) {
if (err) {
console.log(err);
res.json({ error: 'There was an error' });
}
else {