Skip to content

Instantly share code, notes, and snippets.

@gws
gws / cognitect_aws_api_web_identity.clj
Created December 31, 2020 18:33
Cognitect AWS API with web identity
;; Copyright 2020 Gordon Stratton
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
@gws
gws / missing_keys_specs.clj
Created October 19, 2017 17:01 — forked from stuarthalloway/missing_keys_specs.clj
I think it would be a mistake to introduce temporal coupling to prevent typos.
;; I think it would be a mistake to introduce temporal coupling to prevent typos.
;; The example program below lets you identify "missing" keys specs at
;; the time and place of your choosing, and then handle them as you
;; deem appropriate, without imposing those decisions on other
;; users of spec.
(require '[clojure.spec.alpha :as s]
'[clojure.set :as set])
@gws
gws / reading-joins-and-unions-preserving-remotes.clj
Created May 3, 2017 15:41
Om.next: reading joins and unions while preserving remotes
;; Attribution note: this was taken from @petterik on Slack on 2017-05-02
;; Here are two functions I use for reading nested queries, joins and unions.
(defn read-join [{:keys [parser query target ast] :as env}]
(let [ret (parser env query target)]
(if target
(when (seq ret)
{target (assoc ast :query ret)})
{:value ret})))
@gws
gws / maybe_monad.clj
Last active August 29, 2015 14:03
Using the Maybe monad in hypothetical Ring middleware
(ns maybe-monad
(:require [clojure.algo.monads :refer [domonad maybe-m]]
[myapp.magic :as magic]))
;; Non-monadic version
(defn wrap-user
"Add user information to the request map if logged in."
[handler]
(fn [request]
@gws
gws / keybase.md
Last active August 29, 2015 14:00

Keybase proof

I hereby claim:

  • I am gws on github.
  • I am gws (https://keybase.io/gws) on keybase.
  • I have a public key whose fingerprint is 13E3 B721 BBA7 EB29 C610 A71C 5D5F 3485 F793 5DE0

To claim this, I am signing this object:

@gws
gws / Ip.php
Created June 30, 2010 03:50
Class for dealing with IPv4 and IPv6 addresses, specifically supporting storage in a relational database
<?php
/**
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* gordon.stratton@gmail.com wrote this file. As long as you retain this notice
* you can do whatever you want with this stuff. If we meet some day, and you
* think this stuff is worth it, you can buy me a beer in return.
* ----------------------------------------------------------------------------
*/