Skip to content

Instantly share code, notes, and snippets.

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

BideoWego BideoWego

:octocat:
Yarp
View GitHub Profile
@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 / 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 / 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 / chunk.js
Created April 30, 2018 22:44
JavaScript chunk array generator example
function * chunkGen(collection, size=2, i=0) {
for (; i < collection.length; i += size) {
yield collection.slice(i, i + size);
}
}
function chunk(collection, size=1) {
const chunked = [];
const gen = chunkGen(collection, size);
let c = gen.next();
@BideoWego
BideoWego / comments.snippet.json
Created May 16, 2018 00:35
VSCode Snippets and Settings
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
@BideoWego
BideoWego / .bashrc
Created June 8, 2018 15:12
My Windows Dotfiles
echo ''
echo "Hello $(whoami)!"
echo ''
# ------------------------------------
# Directory Shortcuts
# ------------------------------------
alias back='cd $OLDPWD'
alias up='cd ..'
@BideoWego
BideoWego / 2d_array_util_functions.js
Last active June 11, 2018 17:47
2D array utility functions
/**
* Creates and returns a 2D array range from the source array
* @param {Array} array - The source array
* @param {number} y - The y position from which to start the range
* @param {number} x - The x position from which to start the range
* @param {number} h - The height of the range
* @param {number} w - The width of the range
* @returns {Array} The selected range
*/
@BideoWego
BideoWego / promises.js
Created September 14, 2018 14:41
Error handling and stack traces in promise chain catches etc...
function eq(a, b) {
return new Promise(function(resolve, reject) {
a === b ?
resolve(`${ a } === ${ b }`) :
reject(`${ a } !== ${ b }`);
});
}
function eqs(a, b) {
return new Promise(function(resolve, reject) {
@BideoWego
BideoWego / linked_list.js
Created November 21, 2018 20:25
Simple linked list implementation in javascript
class Node {
constructor(value, next) {
this.value = value;
this.next = next;
}
}
class LinkedList {
constructor() {
this.head = null;
@BideoWego
BideoWego / estimated_time_remaining.js
Last active December 6, 2018 16:20
Calculate and output the estimated time remaining on a large number of batched promises and asynchronous tasks
var NUM_COUNT = 1000;
var _nums;
function _everyFiveWaitASecond() {
var chunk = function(i, results) {
results = results || [];
console.log('chunk(', i, ')');
if (!_nums.length) {