Skip to content

Instantly share code, notes, and snippets.

Shaun Scovil sscovil

Block or report user

Report or block sscovil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View simple-cache-example.php
class API {
public static function fetchUser($userID) {
static $cache = [];
$url = "";
$method = "GET";
if (isset($cache[$url][$method][$userID])) {
sscovil / public.asc
Last active May 7, 2018
PGP Public Key
View public.asc
Comment: GPGTools -
sscovil / until.js
Created Feb 20, 2018
A simple utility for Node.js to wait until a predicate function returns truthy before moving on; for use with ES6 async/await syntax.
View until.js
* Utility that waits for @predicate function to return truthy, testing at @interval until @timeout is reached.
* Example: await until(() => spy.called);
* @param {Function} predicate
* @param {Number} interval
* @param {Number} timeout
* @return {Promise}
sscovil / base.js
Last active Jan 2, 2018
Objection.js base model with code coverage
View base.js
'use strict';
const Knex = require('knex');
const { knexSnakeCaseMappers, Model } = require('objection');
const uuid = require('uuid');
const knex = Knex({
client: 'pg',
connection: {
sscovil / custom.css
Last active May 24, 2017
CSS Exercise: What will the output look like, based on the CSS? By only editing custom.css, change the color of "Item 1" to purple.
View custom.css
/* Add custom CSS rules here */
sscovil / en.json
Last active Mar 30, 2020
Node Express server with i18next. Language files go in a `locales/` directory.
View en.json
"home": {
"title": "Hello World!"
sscovil / mixin.js
Created Oct 5, 2016
Shallow (non-recursive) object key-to-camelCase mapper Lodash mixin
View mixin.js
const _ = require('lodash');
function camelCaseKeys(obj) {
return _.mapKeys(obj, (value, key) => {
return _.camelCase(key);
sscovil / index.js
Last active Sep 17, 2016
Node.js recipe for an index.js file that exports all other .js files in the same directory.
View index.js
'use strict';
const fs = require('fs');
const JS_FILE = /^((?!(index)).)*\.js$/;
const JS_FILE_EXTENSION = /\.js$/;
.filter(file => JS_FILE.test(file))
.forEach(file => exports[file.replace(JS_FILE_EXTENSION, '')] = require(`./${file}`));
sscovil / all.js
Created May 12, 2016
Use multiple JS files as defaults for nconf:
View all.js
module.exports = {
ENV: 'set by development.js',
ARG: 'set by development.js',
DEV: 'set by development.js'
sscovil / renameProperty.js
Created Mar 10, 2016
A JavaScript function for renaming an object property.
View renameProperty.js
function renameProperty(object, oldKey, newKey) {
if (object instanceof Object && object.hasOwnProperty(oldKey) && oldKey !== newKey) {
Object.defineProperty(object, newKey,
Object.getOwnPropertyDescriptor(object, oldKey));
delete object[oldKey];
You can’t perform that action at this time.