Skip to content

Instantly share code, notes, and snippets.

@ah45
ah45 / juxt_validate.clj
Created September 4, 2023 12:11
Using `juxt` to compose and apply multiple validation functions against the same value
(ns juxt-validate
(:require [clojure.string :as string]))
(defn validate-format
[v]
(if (every? #(contains? v %) #{:name :email :id})
[:ok v]
[:error {:invalid-format "expected id, name, and email"}]))
(defn validate-email
(ns deferred-fn-output-schema-validation
(:require
[manifold.deferred :as d]
[schema.core :as s]
[schema.spec.core :as s.spec]
[schema.spec.leaf :as s.leaf]
[schema.macros :as s.macros]
[schema.utils :as s.utils]))
(defrecord Deferred [schema]
@ah45
ah45 / profiles.clj
Last active July 18, 2019 15:40 — forked from the-frey/profiles.clj
lein REPL alias
;; in ~/.lein/profiles.clj
{;; a distinct cider-nrepl profile
:cider-nrepl {:plugins [[cider/cider-nrepl "0.22.0-beta1"]
[refactor-nrepl "2.4.0"]]}
;; with an alias to always use it when running `lein repl`
:user {:aliases {"repl" ["with-profile" "+cider-nrepl" "repl"]}}
@ah45
ah45 / profiles.clj
Last active April 18, 2019 12:31
profiles.clj
{:test-refresh {:plugins [[com.jakemccrary/lein-test-refresh "0.23.0"]]
:test-refresh {:notify-command ["terminal-notifier" "-title" "Tests" "-message"]
:quiet true
:changes-only true}}
:dev {:dependencies [[criterium "0.4.4"]]}
:cider-nrepl {:plugins [[cider/cider-nrepl "0.21.1"]
[refactor-nrepl "2.4.0"]]}
:eftest {:plugins [[lein-eftest "0.5.7"]]
:eftest {:multithread? :vars
:thread-count 4}}

Keybase proof

I hereby claim:

  • I am ah45 on github.
  • I am ah45 (https://keybase.io/ah45) on keybase.
  • I have a public key whose fingerprint is B072 177B 3D8C 46B3 7E95 2785 38BB DA97 7152 B5F2

To claim this, I am signing this object:

F# SPA Live Development

Pieces of the puzzle:

  • F#
  • Fable
  • Webpack
  • Suave / Freya / the .NET web framework of your choice
@ah45
ah45 / Capacity Planning Problem Definition.md
Created November 7, 2016 10:53
Constraint Based Scheduling

Following on from a meeting with Simon, Ed, and Bryan. It seems like we’re trying to answer two questions:

  • Where are we overloaded?
  • What aren't we using? (That we should look to find or fit work to.)

Different contexts:

  • Managing current load
  • Always starts with released shop orders.
@ah45
ah45 / railway_oriented_programming.clj
Last active January 16, 2024 13:31
Railway Oriented Programming in Clojure using (funcool) Cats
(ns railway-oriented-programming
"An adaptation of [Railway Oriented Programming](rop) using the
[Cats](cats) library in Clojure.
[rop]: http://fsharpforfunandprofit.com/posts/recipe-part2/
[cats]: https://github.com/funcool/cats"
(:require [cats.builtin]
[cats.core :as cats]
[cats.monad.either :as either]))
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
Dim p As Integer
For i = 1 To Worksheets.Count
If (Worksheets(i).Name <> "Data") Then
For p = 1 To Worksheets(i).PivotTables.Count
Worksheets(i).PivotTables(p).PivotCache.Refresh
Next p
End If
@ah45
ah45 / transit-xhr.cljs
Created April 17, 2015 14:14
Clojurescript Transit XHR Handler
(ns thoth.transit-xhr
(:require [cljs-time.format :as tf]
[cognitect.transit :as tr]
[com.cognitect.transit.types :as trt]
[goog.events :as events])
(:import [goog.net XhrIo]))
(def http-methods
"The HTTP request codes we support Transit payloads in."
{:get "GET"