Skip to content

Instantly share code, notes, and snippets.

View BideoWego's full-sized avatar
:octocat:
Yarp

Chris Scavello BideoWego

:octocat:
Yarp
View GitHub Profile
@BideoWego
BideoWego / deploy_react_express_heroku_surge\checklist.md
Last active October 22, 2020 11:26
Deploy React to Surge and Express to Heroku Checklist

Deploy Full-Stack React/Express App to Heroku and Surge

Express/Heroku

CORS Server-Side

  1. Set NODE_ENV to production on Heroku with heroku config:set NODE_ENV=production
  2. This sets the NODE_ENV environment variable on Heroku
@BideoWego
BideoWego / dictionary.json
Created January 26, 2018 02:28
English dictionary in JSON and words in raw text
This file has been truncated, but you can view the full file.
{
"a": "The first letter of the English and of many other alphabets.The capital A of the alphabets of Middle and Western Europe, as alsothe small letter (a), besides the forms in Italic, black letter,etc., are all descended from the old Latin A, which was borrowed fromthe Greek Alpha, of the same form; and this was made from the firstletter (Aleph, and itself from the Egyptian origin. The Aleph was aconsonant letter, with a guttural breath sound that was not anelement of Greek articulation; and the Greeks took it to representtheir vowel Alpha with the ä sound, the Phoenician alphabet having novowel symbols. This letter, in English, is used for several differentvowel sounds. See Guide to pronunciation, §§ 43-74. The regular longa, as in fate, etc., is a comparatively modern sound, and has takenthe place of what, till about the early part of the 17th century, wasa sound of the quality of ä (as in far).",
"ab": "The fifth month of the Jewish year according to theecclesiastical reckoning, the eleventh by the
@BideoWego
BideoWego / app.js
Last active December 11, 2017 20:13
Mongoose - Setup and boilerplate files for Mongoose with seeds, config for multiple environment databases and a REPL
// Put this before your routes
// ----------------------------------------
// Mongoose
// ----------------------------------------
const mongoose = require('mongoose');
app.use((req, res, next) => {
if (mongoose.connection.readyState) {
next();
} else {
@BideoWego
BideoWego / random-date.js
Created December 8, 2017 05:04 — forked from miguelmota/randomDate.js
Random date in JavaScript
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()));
@BideoWego
BideoWego / command-line_args.js
Created November 25, 2017 21:39
Regex to capture command-line arguments separated by spaces but group strings surrounded in quotes
/*
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\'' ]
@BideoWego
BideoWego / ternary_if_else_if_else.js
Last active December 1, 2017 20:59
Ternary if, else if, else... chain
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' :
@BideoWego
BideoWego / algos.js
Created September 26, 2017 19:42
Algo Problems
/*
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
@BideoWego
BideoWego / submlime-emmet-jsx-tab-trigger.js
Last active April 29, 2017 20:11 — forked from wesbos/tab-trigger.js
How to properly get a TAB trigger working with Emmet inside of JSX
{
"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": [
{
@BideoWego
BideoWego / helpers.pagination_helper.js
Created April 19, 2017 22:06
Pagination algo in a project context
const _ = require('lodash');
function _createPages(current, max, delta) {
// Return nada if we got
// no pages
if (!max) {
return [];
}
@BideoWego
BideoWego / pagination.js
Created April 19, 2017 21:16
A simple an effective pagination algorithm with an O(n) time complexity where n is the number of pages in the range `(current - delta) ... (current + delta) + 2`
// 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