Skip to content

Instantly share code, notes, and snippets.

View BigAB's full-sized avatar
🇨🇦
JavaScript Loving Canadian

Adam L Barrett BigAB

🇨🇦
JavaScript Loving Canadian
View GitHub Profile
@BigAB
BigAB / machine.js
Created September 15, 2020 21:01
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@BigAB
BigAB / queue.js
Created November 29, 2018 17:01
This is a simple queue structure, but it demostrates 2 things, private data in a class, and having both a construtctor and a factory function that do the exact same thing
function Queue(){
return createQueue();
}
function createQueue() {
const queue = [];
const q = Object.create(Queue.prototype, {
constructor: {
configurable: true,
enumerable: false,
value: Queue,
@BigAB
BigAB / ylem-mission.md
Last active May 31, 2018 16:22
On ylems mission

High Level Goals

  1. To generate high quality qualified sales leads.
  2. To be effective developers because we know and can fix big chunks of the stack.
  3. To give our developers a fun outlet for creativity.

Focus on "simpler and more scalable state management"

I think it's in Bitovi's best interests to start out pursuing the following mission and identity:

@BigAB
BigAB / old-school.js
Created March 3, 2018 01:04
A little snippet to use ES2018 code to old school load a bunch of UI Widgets, where the HTML configures the options of the UI widget and which element is to be enhanced with a stateful UI widget
const uiWidgets = {
draggable: class Draggable {
constructor({
element,
options: { dropZones = [], dragUI = 'standard' } = {}
}) {
Object.assign(this, {
element,
dropZones,
dragUI,
@BigAB
BigAB / ssl-on-localhost.md
Created October 31, 2017 17:06
A set of really simple commands to enable https over localhost for Mac

From paulbrowne.xyz

cd; mkdir .ssl

openssl req -newkey rsa:2048 -x509 -nodes -keyout .ssl/localhost.key -new -out .ssl/localhost.crt -subj /CN=localhost -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:localhost')) -sha256 -days 3650

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain .ssl/localhost.crt
@BigAB
BigAB / async-transform.js
Last active November 23, 2016 15:48
Async Transform Function in JavaScript
/***************************************************/
function asyncTransform( transforms, val, context ) {
if (typeof val === 'undefined') {
return v => asyncTransform(transforms, v, context);
}
const v = Promise.resolve(val);
if (context) {
transforms = transforms.map( t => v => t.call(context, v));
}
@BigAB
BigAB / README.md
Last active September 29, 2016 08:20
CanReact problem: props always win

This just tries to demostrate the fact that because attr1 is supplied by props, even though the viewModels property keeps getting set, it just keeps going back to the props value because of the current implementation. To run the demo:

  • clone this repo (a gist is a repo)
  • run npm install (or npm i if you're nasty)
  • run npm start and checkout http://localhost:3000/
@BigAB
BigAB / my-stache-bindings.md
Last active September 23, 2016 04:28
Do we need more stache binding than this?

two-way binding

ParentVM to ChildVM Attr / DOM Attr¹

attribute="{ vmKey }"

one-way parent to child

attribute="{{ vmKey }}"

Keybase proof

I hereby claim:

  • I am bigab on github.
  • I am adamlbarrett (https://keybase.io/adamlbarrett) on keybase.
  • I have a public key whose fingerprint is ED95 FF07 C17A 96ED 6506 D8CB 90F7 8A7F 7822 FA8C

To claim this, I am signing this object:

@BigAB
BigAB / jwt-issuer-architecture.md
Created June 29, 2016 05:26
JWT Issuer Architecture Idea

Another Idea for JWT Issuer Architecture

Thinking about how to secure the refresh-token for the web gave me an idea for what I think would be a pretty good set up for issueing JWT access-tokens and refresh-tokens.

What if...

refresh-tokens are issued by a central stateful server (backed by a DB), that maintains a black list.

  • black list occasionally runs a "job" to remove any entries that have expired, keeping it light and lean
  • refresh-tokens are only available at a specific domain, so that we can use secure cookies for the web