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

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
@BigAB
BigAB / arrow-functions.md
Last active June 28, 2016 18:10
Arrow functions and code style

When deciding on which code style to use, under different circumstances (i.e. number of parameters, return value, etc.) a good solid rule for consistency and terseness is: Always use the minimum required syntax for the situation

The minimum does not include variable/parameter names, which should should be semantic to the meaning or general depending on how the function will be used. Using an unused parameter name to save one char (like _ => 2*2) is confusing and should be avoided.

With this rule in mind we end up with this:

// no params
() => {}                    // "noop" no parameters, no operations, no return value
() => value + 1             // no parameters, one line operation, a return value (that is not an object)
@BigAB
BigAB / gulpfile.js
Created February 22, 2016 15:54
Use includePaths to import bootstrap into your project
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('style', function() {
return gulp.src('style.scss')
.pipe(sass({
includePaths: ["node_modules/bootstrap/scss"]
}))
.pipe(gulp.dest('./'));
});
@BigAB
BigAB / simple-author-model.js
Created January 8, 2016 06:06
Simple test of Feathers-Mongoose
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var authorSchema = new Schema({
name: String,
age: Number,
blogs: [{ type: Schema.Types.ObjectId, ref: 'Blog' }]
});
var Author = mongoose.model('Author', authorSchema);
@BigAB
BigAB / day2.js
Created December 4, 2015 20:02
Advent of code day 2 answer - adventofcode.com
function calculateWrappingPaperNeeds(input) {
return input.split('\n')
.reduce((sqFt, eq) => {
var d = eq.split('x');
var l = d[0], w = d[1], h = d[2];
sqFt += 2*l*w + 2*w*h + 2*h*l;
sqFt += Math.min(l*w, w*h, h*l); // little extra
return sqFt;
}, 0);
}
@BigAB
BigAB / Live-Sortable-Lists-with-CanJS.markdown
Created April 6, 2015 20:45
Live Sortable Lists with CanJS

Live Sortable Lists with CanJS

Using CanJS and the sortable-plugin, having live sortable lists becomes easy, leading to an simple and expressive template that just works.

A Pen by Adam Barrett on CodePen.

License.

@BigAB
BigAB / .eslintrc
Created March 27, 2015 02:21
ESLint .eslintrc file for configuring eslint
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"arrowFunctions": true, // enable arrow functions
"modules": true, // enable modules
"binaryLiterals": false, // enable binary literals
"blockBindings": true, // enable let and const (aka block bindings)
"classes": true, // enable classes
"defaultParams": true, // enable default function parameters
@BigAB
BigAB / dabblet.css
Last active August 29, 2015 14:12
A pretty nav
/* A pretty nav */
body {
color: #eee;
background: rgba(0, 0, 0, 0.8);
font-family: sans-serif;
font-size: 24px;
}
nav {
text-align: right;