Skip to content

Instantly share code, notes, and snippets.

@danscan
danscan / policy.js
Created January 25, 2016 16:55
Policy function
const db = {
usersBySessionToken: {
'1': {
id: 1,
name: 'Dan',
},
},
postsById: {
'2': {
@danscan
danscan / policy.js
Last active January 25, 2016 17:03
Policy function
function requestUserOwnsPost(requestUser, post) {
return requestUser.id === post.owner;
}
const db = {
postsById: {
'2': {
id: 2,
owner: 1,
body: 'hey',

Backathon

See what the other hackers are working on. If you like an hack, play with it.
If not, remove it.

Load Dependencies

_                   = require 'underscore'                  # documentcloud/underscore
@danscan
danscan / keybase.md
Created January 17, 2021 19:37
keybase.md

Keybase proof

I hereby claim:

  • I am danscan on github.
  • I am danscan (https://keybase.io/danscan) on keybase.
  • I have a public key ASAS_Adf3xZSUSirUuF9Cfjd_Bf9PZ_diAinf-zLiouIfwo

To claim this, I am signing this object:

@danscan
danscan / StatefulService.swift
Created March 28, 2025 18:35
A Swift class designed for injecting dependency services with separate live/preview/test implementations into Swift apps using the Observation framework.
import Observation
@Observable class StatefulService<State, API> {
typealias Stream = StateStream<State>
typealias StateStreamTask = Task<Void, Never>
typealias OnStateChange = (State) -> Void
/// The API of the service
let api: API
/// The state of the service