Skip to content

Instantly share code, notes, and snippets.

View aarongeorge's full-sized avatar
🤖

ADG aarongeorge

🤖
View GitHub Profile

macOS Reinstall Checklist

Clean install without USB
sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/startosinstall --agreetolicense --eraseinstall

Set “Key Repeat” to “Fast”
defaults write -g InitialKeyRepeat -int 15

Set “Delay Until Repeat” to “Short”
defaults write -g KeyRepeat -int 2

@aarongeorge
aarongeorge / EventEmitter.ts
Last active October 27, 2020 22:51
Flexible Event Emitter for TypeScript
/**
* EventEmitter
*
* @desc An event emitter
*/
interface Listener {
cb: (...args: any[]) => void
count: number
name: string
@aarongeorge
aarongeorge / Tween.js
Last active March 17, 2021 06:29
A minimal tweening class, utilising stepped updates with optional easing
// A minimal tweening class, utilising stepped updates with optional easing
class Tween {
constructor ({ from, to, change, steps, easeFn, duration, cb }) {
this.from = from
this.to = typeof to === 'undefined' ? from + change : to
this.change = typeof change === 'undefined' ? to - from : change
this.steps = typeof steps === 'number' ? steps : duration / 16
this.duration = duration
this.easeFn = typeof easeFn !== 'function' ? t => t : easeFn
this.cb = typeof cb === 'undefined' ? () => {} : cb
@aarongeorge
aarongeorge / cloudSettings
Last active April 30, 2020 16:47
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-04-30T16:47:44.301Z","extensionVersion":"v3.4.3"}
@aarongeorge
aarongeorge / propertyValidator.js
Last active July 1, 2020 00:28
A runtime property validator for JS objects
/**
* Property Validator
*
* @desc A runtime property validator for JS objects
* @usage:
* const model = new PropertyValidator({
* 'propName': {
* 'type': 'any'|'array'|'boolean'|'custom'|'date'|'element'|'function'|'number'|'object'|'regExp'|'string'
* 'required': true|false,
* 'validateFn': a function that takes one param and returns true or false. Only works if `type` is `custom`
@aarongeorge
aarongeorge / remap.js
Last active November 30, 2020 07:22
Linear remapping in JavaScript. When n, a and b are equal, x will be returned instead of NaN (Due to divide by zero)
const remap = (n, a, b, x, y) => x + (y - x) * (n - a) / (b - a) || x
/*
Usage:
n = Number
a = from lower bound
b = from upper bound
x = to lower bound
y = to upper bound
@aarongeorge
aarongeorge / JWTPayloadExample.js
Last active November 2, 2019 08:13
Example of a JWT Payload with all Registered Claims
const timeNow = new Date()
const payload = {
iss: 'http://backend.com', // Issuer - Identifier of who provided this JWT
sub: 'uniqueIdOfUser', // Subject - Who is supposed to be using this JWT (The value should mean something for `aud`)
aud: ['http://frontend.com', 'http://backend.com'], // Audience - Who should be consuming this JWT
exp: new Date(new Date(timeNow).setDate(timeNow.getDate() + 7).getTime(), // Expiration Time - When this JWT should no longer be accepted by the `aud`
nbf: timeNow.getTime(), // Not Before - When this JWT should start being accepted by the `aud`
iat: timeNow.getTime(), // Issued At - When this JWT was issued
jti: 'uniqueIdForThisJWT' // JWT ID - Unique ID that the `aud` can use to blacklist/whitelist the JWT even if `exp` and `nbf` requirements are met
@aarongeorge
aarongeorge / modifyDate.ts
Last active April 6, 2020 00:42
Modify JavaScript Date - Add and/or Subtract Years, Months, Weeks, Days, Hours, Minutes, Seconds and Milliseconds
const modifyDate = (date: Date, options: {[key in 'years' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds']?: number} = {}) => {
const modifiedDate = new Date(date)
if (options.years) modifiedDate.setFullYear(modifiedDate.getFullYear() + options.years)
if (options.months) modifiedDate.setMonth(modifiedDate.getMonth() + options.months)
if (options.weeks) modifiedDate.setDate(modifiedDate.getDate() + options.weeks * 7)
if (options.days) modifiedDate.setDate(modifiedDate.getDate() + options.days)
if (options.hours) modifiedDate.setHours(modifiedDate.getHours() + options.hours)
if (options.minutes) modifiedDate.setMinutes(modifiedDate.getMinutes() + options.minutes)
if (options.seconds) modifiedDate.setSeconds(modifiedDate.getSeconds() + options.seconds)
@aarongeorge
aarongeorge / RangeGrouping.js
Created August 28, 2019 01:59
Given an array of ranges, group overlapping ranges in an array and return an array of the groups
const ranges = [
{
'start': 6,
'end': 8
},
{
'start': 3,
'end': 6
},
{

I was looking to see if there are any CSS pre-processors that handle scoped variables inside of their mixins. The goal was to be able to create a breakpoint mixin that auto-injects variables defined in a map/hash.

This is how I've been forced to do it with Sass

SCSS Input

$BREAKPOINTS: (
    default: min-width 0    6  10 10 10 10 24,
    phablet: min-width 480  6  10 10 10 10 24,