Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Hayes joeyred

View GitHub Profile
@joeyred
joeyred / reporter.js
Last active Dec 9, 2020
Error reporter wrapper for Sentry to prevent reporting to Sentry in dev, but still logging any resulting message or error.
View reporter.js
/* eslint-disable no-console */
import * as Sentry from '@sentry/browser';
let production = false;
/**
* Initialize reporter. This should be done as soon as possible.
* @method initReporter
* @param {Boolean} isProduction - If the app is currently running in
* production or not.
@joeyred
joeyred / ratio.js
Last active Dec 9, 2020
Utilities for dealing with aspect ratio and scaling of rectangles.
View ratio.js
/**
* Copyright (c) 2019-present, Brian J. Hayes.
*
* https://github.com/joeyred
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export function fixedDecimalPlaces(number, places) {
View arraysMatch.js
function arraysMatch(arrayOne, arrayTwo) {
let match = false;
if (arrayOne.length !== arrayTwo.length) {
return false;
}
for (let indexOne = 0; indexOne < arrayOne.length; indexOne += 1) {
// For checking for a match to the current ArrayOne value
let valueMatch = false;
for (let indexTwo = 0; indexTwo < arrayTwo.length; indexTwo += 1) {
@joeyred
joeyred / gulpfile.js
Last active Dec 13, 2016
Use Jekyll with gulp.js while leveraging the use of a `--production` flag when running `gulp` to set the environment in Jekyll to production as well.
View gulpfile.js
var gulp = require('gulp');
var yargs = require('yargs');
var DEPLOY = Boolean(yargs.argv.production);
/**
* Jekyll Task
*
* Make Jekyll run stuff when told to by gulp.
*
@joeyred
joeyred / debug.js
Created Nov 30, 2016
A little debugging object.
View debug.js
/**
* Controls whether debug functions have any output to console.
* @type {Boolean}
*/
var DEBUG_IS_ENABLED = true;
/**
* Debug constructor
* @method Debug
* @param {string} objectName The name of the parent object of all logged data