Skip to content

Instantly share code, notes, and snippets.

View raymcdermott's full-sized avatar

Ray McDermott raymcdermott

  • OpenGrail
  • Belgium
View GitHub Profile
@raymcdermott
raymcdermott / gist:c961c3dd37d425af9c35
Created March 30, 2015 14:28
Run a deployment from Bamboo to Heroku with independence from locally installed tools
#!/usr/bin/env bash
############ CONFIGURE GIT from this repo
git config user.email "bamboo@company.com"
git config user.name "Bamboo Dev"
# Add a remote master to Heroku (if one does not exist)
(git remote -v | grep "^heroku" > /dev/null) ||
heroku git:remote --app $HEROKU_APP_NAME --org $HEROKU_ORG_NAME
@raymcdermott
raymcdermott / core.clj
Last active September 23, 2015 23:11
Minimal configurator
(ns car-configurator.core
(:require [schema.core :as s]))
; NO CODE YET ... Just data
;---> define some basic attributes
(def fuel (s/enum :diesel :petrol :hybrid))
(def engine {:name s/Str :fuel fuel :volume s/Num :bhp s/Int}) ; c02, etc.
(def colour {:name s/Str :rgb {:red s/Int :green s/Int :blue s/Int} :hex s/Int}) ; metallic, etc.
; STILL NO CODE YET ... Just data
@raymcdermott
raymcdermott / datomic-component-crud.clj
Last active December 7, 2015 21:13
CRUD on component entities ... more support than comes out of the box with Datomic
(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)
@raymcdermott
raymcdermott / core.async filtering by time
Last active June 6, 2018 14:12
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 / source-gold-diff.clj
Last active March 24, 2016 23:08
Obtain diff between source data and golden view
(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)))

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

; 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]
@raymcdermott
raymcdermott / decoding-jwt.clj
Last active October 26, 2022 05:47
Simple JWT Decoder in Clojure
(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)
;; 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 / depgen.md
Last active November 25, 2019 19:20
Adhoc CLJS dependency generation

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.