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:908742
Created April 7, 2011 21:15
simple recursion
def scrubOut(line: String, keys: Seq[String]): String = {
// Optimizations... most likely to the left
if (!line.contains("=") || !line.contains("\"") || keys.isEmpty || containsKeys(false, line, keys) == false)
line
else
scrubOut(line.replaceAll(keys.head + "=\".*?\"", keys.head + "=\"****\""), keys.tail)
}
@raymcdermott
raymcdermott / gist:908753
Created April 7, 2011 21:21
recursive java
public String scrubOut(String line, Collection<String> keys) {
if (keys.isEmpty()) return line;
else {
String key = keys.iterator().next();
keys.remove(key);
return scrubOut(line.replaceAll(key + "=\".*?\"", key + "=\"****\""), keys);
}
}
@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 / 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 / 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
;; 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.

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: