Skip to content

Instantly share code, notes, and snippets.

View jmglov's full-sized avatar

Josh Glover jmglov

View GitHub Profile
@jmglov
jmglov / clj-prod-project.clj
Created January 30, 2019 13:08
Clojure in Production: Lein project.clj
(defproject clj-prod "0.1.0-SNAPSHOT"
:description "Clojure in Production"
:license {:name "MIT"
:url "https://opensource.org/licenses/MIT"}
:dependencies [[org.clojure/clojure "1.10.0"]
[amazonica "0.3.139"]
[cheshire "5.8.1"]])
@jmglov
jmglov / clj-prod-01.md
Created January 30, 2019 09:34
Clojure in Production - Lesson 01: Getting Started

Clojure in Production - Lesson 1

Getting started

Our production system

Before we get started with any coding, let's be responsible engineers and do a little design. And before we get started with any design, let's be responsible engineers and ask our "product owner" (this document) what we're building.

@jmglov
jmglov / fpwc-01.clj
Last active February 2, 2019 13:33
Functional Programming with Clojure, lesson 01
;; # Functional Programming with Clojure - L01
;; ## Why does Clojure have so many parens?
;; Most programming languages use infix notation for operators:
;; `1 + 2 + 3 + 4`
;; And put the name of the function before the parens grouping its arguments:
@jmglov
jmglov / skeys.clj
Created February 6, 2018 17:47
Disgusting aero reader macro
(defmethod aero.core/reader 'skeys [_ _ {:keys [req opt req-un opt-un] :as key-defs}]
(let [req (or req [])
opt (or opt [])
req-un (or req-un [])
opt-un (or opt-un [])]
(eval `(s/keys :req ~req
:opt ~opt
:req-un ~req-un
:opt-un ~opt-un))))
@jmglov
jmglov / .spacemacs
Created January 14, 2018 07:21
.spacemacs
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@jmglov
jmglov / mob-programming.md
Last active March 4, 2024 19:30
Mob Programming Dojo
@jmglov
jmglov / thread-first.erl
Created December 20, 2016 10:23
Clojure's thread-first macro, implemented as an Erlang function
'-?>'(X, Fs) ->
reduce(
fun({F, A}, Acc) -> apply(F, [Acc|A]);
({M, F, A}, Acc) -> apply(M, F, [Acc|A]);
(F, Acc) when is_function(F, 1) -> F(Acc)
end, X, Fs).
@jmglov
jmglov / spec_test_utils.clj
Created September 14, 2016 12:53
Utility functions for using `clojure.spec` generative tests in standard `clojure.test` unit tests.
(ns spec-test-utils
(:require [clojure.spec.test :as stest]
[clojure.test :refer [is testing]]))
(defn- check [function num-tests]
(if num-tests
(stest/check function {:clojure.spec.test.check/opts {:num-tests num-tests}})
(stest/check function)))
(defn checking
@jmglov
jmglov / init.el
Created September 6, 2016 07:23
Full init.el
;; Packages
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/") t)
(add-to-list 'package-archives
'("melpa.org" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
@jmglov
jmglov / ping_pong_go.clj
Created July 6, 2016 10:57
Non-blocking version of core.async ping-pong game
(ns ping-pong-go
(:require [clojure.core.async :as async :refer [<! >!]]))
(defn ping [ch]
(println "Ping")
(>! ch :ping)
(<! (async/timeout 500)))
(defn pong [ch]
(println "Pong")