Skip to content

Instantly share code, notes, and snippets.

View sdd's full-sized avatar

Scott Donnelly sdd

View GitHub Profile

Keybase proof

I hereby claim:

  • I am sdd on github.
  • I am scottyd (https://keybase.io/scottyd) on keybase.
  • I have a public key ASBV5fFbgmTHD1YD_B7qx8yjb0zIunfu9LVnRFgHQeQkrgo

To claim this, I am signing this object:

@sdd
sdd / test.js
Created January 19, 2017 22:14
audience vs aud
const Koa = require('koa');
const jwt = require('koa-jwt');
const expect = require('chai').expect;
const request = require('supertest');
const app = Koa();
// paste these into jwt.io to see the contents
const tokenWithAudience = "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoidGVzdCIsImF1ZGllbmNlIjoiaHR0cDovL215YXBpL3Byb3RlY3RlZCIsImlzc3VlciI6Imh0dHA6Ly9pc3N1ZXIifQ.c6bLTAnWLt-Iv-KPJt6pEPhZuIRERSCnIT1OxQSzRT0";
const tokenWithAudValid = "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoidGVzdCIsImF1ZCI6Imh0dHA6Ly9teWFwaS9wcm90ZWN0ZWQiLCJpc3MiOiJodHRwOi8vaXNzdWVyIn0.EEVyqH9shrvqJ6YpWKInnXTESzPam_PWfpsSVeEjWjY";
Verifying myself: My Bitcoin username is +scottyd. https://onename.io/scottyd
@sdd
sdd / Module.js
Last active January 21, 2019 11:37
Javascript Module pattern template. Shows a class with a constructor and public/private methods/properties. Also shows compatibility with CommonJS(eg Node.JS) and AMD (eg requireJS) as well as in a browser.
/**
* Created with JetBrains PhpStorm.
* User: scotty
* Date: 28/08/2013
* Time: 19:39
*/
;(function(global){
"use strict";
var M = function() {
@sdd
sdd / mage-constraints.sql
Created June 21, 2012 10:56 — forked from cgdangelo/mage-constraints.sql
Recreate foreign keys for a Magento installation, after you fire the idiot who deleted all of them.
# one-liner for generating this: mysqldump --no-data -uroot magento1600 | nawk '{if(match($0, /CREATE TABLE `(.*)`/, matchesT)) { the_table = matchesT[1]; } if(match($0, /(CONSTRAINT .*),?/, matchesK) && the_table) { the_key = gensub(/,?$/, "", matchesK[1]); the_key = gensub(/^ */, "", the_key); print "ALTER TABLE `" the_table "` ADD", the_key ";"; }}'
ALTER TABLE `admin_rule` ADD CONSTRAINT `FK_ADMIN_RULE_ROLE_ID_ADMIN_ROLE_ROLE_ID` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `api_rule` ADD CONSTRAINT `FK_API_RULE_ROLE_ID_API_ROLE_ROLE_ID` FOREIGN KEY (`role_id`) REFERENCES `api_role` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `api_session` ADD CONSTRAINT `FK_API_SESSION_USER_ID_API_USER_USER_ID` FOREIGN KEY (`user_id`) REFERENCES `api_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `catalog_category_entity_datetime` ADD CONSTRAINT `FK_CAT_CTGR_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID` FOREIGN KEY (`attribute_id