Skip to content

Instantly share code, notes, and snippets.

View robert-stuttaford's full-sized avatar
💭
Clojure!

Robert Stuttaford robert-stuttaford

💭
Clojure!
View GitHub Profile
# Terraform + Ansible
## My assumptions about you:
- You've used neither of these tools.
- You may have used AWS before.
- You get the whole infrastructure in the cloud thing.
It's already available for you to play with right now — please grab it and ask questions!
@robert-stuttaford
robert-stuttaford / circle.env.yml
Last active September 21, 2016 03:22
Set a bunch of env vars on many CircleCI projects via API
AWS_ACCESS_KEY_ID: ABCDEFGHIJKLMNOPQRSTUVWXYZ
AWS_SECRET_ACCESS_KEY: supercalifragilisticexpialidocious
# more: values
# go: here
@robert-stuttaford
robert-stuttaford / fira-code.el
Created August 25, 2016 15:06
FiraCode + Emacs
(when (window-system)
(set-default-font "Fira Code"))
(let ((alist '((33 . ".\\(?:\\(?:==\\|!!\\)\\|[!=]\\)")
(35 . ".\\(?:###\\|##\\|_(\\|[#(?[_{]\\)")
(36 . ".\\(?:>\\)")
(37 . ".\\(?:\\(?:%%\\)\\|%\\)")
(38 . ".\\(?:\\(?:&&\\)\\|&\\)")
(42 . ".\\(?:\\(?:\\*\\*/\\)\\|\\(?:\\*[*/]\\)\\|[*/>]\\)")
(43 . ".\\(?:\\(?:\\+\\+\\)\\|[+>]\\)")
(45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
@robert-stuttaford
robert-stuttaford / keys_with_and_question.clj
Last active June 16, 2016 14:03
Clojure core.spec question: composing s/keys with s/and
;; using Clojure 1.9-alpha7
(ns keys-with-and-question
(:require [clojure.spec :as s]
[clojure.spec.gen :as gen]))
(s/def ::id string?)
(s/def ::active? boolean?)
(s/def ::extra int?)
(s/def ::base (s/keys :req-un [::id] :opt-un [::active?]))
@robert-stuttaford
robert-stuttaford / notes.md
Last active December 24, 2015 21:29
Gain massive leverage in your tech stack with Clojure: Notes
Check out README.md to get started editing Clojure with Emacs.
@robert-stuttaford
robert-stuttaford / web-session-tx-fn.clj
Created July 3, 2013 11:33
using database functions to avoid race conditions between multiple webservers
(defn start-session!
[]
;; put-value! talks to ring's sessions dsl
(put-value! :session-uuid (db/new-uuid)))
(defn uuid
[]
;; get-value talks to ring's sessions dsl
(get-value :session-uuid))
@robert-stuttaford
robert-stuttaford / with.clj
Last active December 19, 2015 07:09
Using Datomic's d/with to query a database as though some transaction had been committed, before actually committing it!
(def conn (d/conn some-uri))
(def some-id 12345)
(defn get-v [db] (ffirst (d/q '[:find ?v :in $ ?e :where [?e :some/attribute ?v]] db some-id)))
(get-v (d/db conn))
;; => :some-value
(def tx [[:db/retract some-id :some/attribute :some-value]