Skip to content

Instantly share code, notes, and snippets.

View DoseOfGose's full-sized avatar

Eric Gose DoseOfGose

View GitHub Profile

Keybase proof

I hereby claim:

  • I am doseofgose on github.
  • I am doseofgose (https://keybase.io/doseofgose) on keybase.
  • I have a public key ASCgphEPHYb2AsVkX0gFgP8SQX8bwnM-Dm7jP5Q-FHlalwo

To claim this, I am signing this object:

@DoseOfGose
DoseOfGose / server.js
Created March 6, 2018 18:20
Simple starter express server I use in many of my personal projects that require sass, a static web server, compression, and setup for parsing API calls
const express = require('express');
const compression = require('compression');
const path = require('path');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const sass = require('node-sass-middleware');
const app = express();
@DoseOfGose
DoseOfGose / default.js
Last active March 6, 2018 18:15
Use node-config to verify required fields have been provided else exit process
// Use defer to perform checking after node-config has gone through default, local, etc. config files
const defer = require('config/defer').deferConfig;
// Example list of required fields - this version assumes we're just checking that key-value pairs are not undefined
// List values as strings of the full value, for example if you need `config.levelOne.levelTwo` in your code add
// the string "levelOne.levelTwo" to the list:
const required = [
"db.server", "db.port", "db.name"
];
@DoseOfGose
DoseOfGose / ng1-window-resize-directive.js
Created July 28, 2016 09:43
Example of a window resize directive that restricts itself to y-only expansion
/*
* Example directive used in a project for window resize. Added restriction to only fire
* event in the situation that the width of the window remains static AND the height is
* increased. Essentially:
* currX === prevX && currY > prevY
*
* The use case for this was to trigger an element's recalculation in this specific
* situation. You can easily remove the checks on the width and height for a more general
* directive.
*/
@DoseOfGose
DoseOfGose / datetimestamp-formated-output.js
Last active July 28, 2016 09:07
Simple example of manually constructing a specific date-time string output from Date object without using toLocaleString
/*
* Simple function to convert valid input for `new Date(input)` to
* the following format:
* 7 June 2016 5:07 am GMT-5
*
* Originally was using date.toLocaleString, but it is inconsistent between
* browser implementations and is not in Safari stable release (it is in the
* nightly build at the moment).
*/
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];