Skip to content

Instantly share code, notes, and snippets.

Avatar

Ray McDermott raymcdermott

View GitHub Profile
View nbb-lambda.adoc

AWS Lambda, now with first class parentheses

A simple, powerful and compelling story for deploying Clojure with no overhead on AWS Lambdas.

NBB
View keybase.md

Keybase proof

I hereby claim:

  • I am raymcdermott on github.
  • I am raymcdermott (https://keybase.io/raymcdermott) on keybase.
  • I have a public key ASBzSH6LGCylAeFE3FiusmnPT-4axjypt15F-CXfalAC3go

To claim this, I am signing this object:

@raymcdermott
raymcdermott / depgen.md
Last active Nov 25, 2019
Adhoc CLJS dependency generation
View depgen.md

Introduction

A conversation started at the Heart of Clojure conference in Belgium on Friday August 2nd 2019.

The group represented project owners from Maria.Cloud, Next.Journal, Klipse and Replete-Web. The projects make significant use of self-hosted CLJS.

This is a proposal to have a service that generates and caches JS files for a specific CLJS dependency (name & version).

Background

The ClojureScript compiler generates JS files for each of an apps stated CLJS dependencies. The runtime environment then loads each of the needed JS files to satisfy the dependency at runtime.

View map-examples.clj
;; Simplest use cases
;; Transform simple input
(map inc [1 2 3 4 5])
(map str [1 2 3 4 5])
(map clojure.string/lower-case ["COBOL" "Ada" "C"])
;; Extract simple input
@raymcdermott
raymcdermott / decoding-jwt.clj
Last active May 12, 2020
Simple JWT Decoder in Clojure
View decoding-jwt.clj
(defn base64-decode
"Utility function over the Java 8 base64 decoder"
[to-decode]
(String. (.decode (Base64/getDecoder) ^String to-decode)))
(defn string->edn
"Parse JSON from a string returning an edn map, otherwise nil"
[string]
(when-let [edn (json/decode string true)]
(when (map? edn)
View gist:1f38ec455df433b96da789a70a4dd346
; TODO: have a way to have this list provided / augmented by users
(def ^:private oidc-discovery
"Map from TLDs to discovery endpoints"
{"auth0.com" ".well-known/jwks.json"
"google.com" ".well-known/openid-configuration"})
(defn- get-jwt-data
"Obtain JWT related data and parse it into a Clojure map"
[endpoint]
View gist:8b5209b129d99fb490e6

The person, one Mr Cuntis Yarvin, at the centre of the #lamdaconf debacle performed an Ask Me Anything on Reddit. One of his defenders on Twitter referenced this response from the AMA as proof that he was not racist.

I appreciate that giving more commentary space to this situation provides the oxygen that our protagonist craves. On the other hand I feel like this is sufficiently important to our community to stand up and defend those people that this person seeks to diminish and damage.

So, with that and a deep breath, let's take this response bit by bit and see whether it works out as a defence by the protagonist as evidence of his lack of racism.

> Amusingly, my "one offensive comment" was actually me repeating something my wife (not at all a 'shitlady') learned in her MFA program at SF State (not at all a Hitler Youth academy). (This is the observati

@raymcdermott
raymcdermott / source-gold-diff.clj
Last active Mar 24, 2016
Obtain diff between source data and golden view
View source-gold-diff.clj
(def api-data {:source-data {:fname "Ray", :last "McDermott", :e-mail "foo@bar.com"},
:golden-view {:first "Ray", :last "McDermott", :email "bar@bar.com", :dob "29/04/2004"},
:mapping {:email :e-mail, :first :fname, :last :last}})
;=> #'user/api-data
(defn source-golden-diff [source-data golden-view source-map]
(let [common-keys (let [keys (clojure.set/intersection (set (keys golden-view))
(set (keys source-data)))]
(into {} (map #(vec [% %]) keys)))
@raymcdermott
raymcdermott / core.async filtering by time
Last active Jun 6, 2018
core.async filtering by time
View core.async filtering by time
(ns green-eggs.core
(:require [clojure.core.async
:as a
:refer [>! <! >!! <!! go chan buffer close! thread
alts! alts!! timeout onto-chan]]
[clj-time.core :as t]
[clj-time.coerce :refer [from-date]]))
;If you were to implement yourself, you could make a `go` that simply pulls from a channel, and adds to another as a
;`[timestamp item]` pair, then finally pushes into an unbounded `chan` that has a transducer that filters based on
@raymcdermott
raymcdermott / datomic-component-crud.clj
Last active Dec 7, 2015
CRUD on component entities ... more support than comes out of the box with Datomic
View datomic-component-crud.clj
(def component-crud
(d/function
'{:lang "clojure"
:params [db entity comp-key]
:code (if-let [db-entity (d/pull db '[*] (:db/id entity))]
(let [db-comps (comp-key db-entity)
user-comps (comp-key entity)
s1 (into #{} (map :db/id db-comps))
s2 (into #{} (map :db/id user-comps))
diffs (clojure.set/difference s1 s2)