Skip to content

Instantly share code, notes, and snippets.

View JacobKorn's full-sized avatar

Anthony Mace JacobKorn

View GitHub Profile
@jimsynz
jimsynz / 01_turnstile.rb
Last active August 29, 2015 14:04
Source code for our No More Mr State Machine talk.
# Our simple example of a Turnstile state machine.
class Turnstile
def initialize
@state = "Locked"
end
def push!
@state = "Locked" if unlocked?
end
@joshnuss
joshnuss / app.js
Last active March 4, 2024 00:01
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection