Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

View GitHub Profile
@dvliman
dvliman / screen-gif.sh
Created August 23, 2020 05:10 — forked from julesjans/screen-gif.sh
Capture iOS Simulator to animated gif
# Turn on the simulator screen capture
xcrun simctl io booted recordVideo ~/simulator.mov
# Convert the iPhone 6s screen shot into a gif:
ffmpeg -i ~/simulator.mov -vf scale=320:-1 -r 6 -f gif -y simulator.gif
(defn pgobj->clj [^org.postgresql.util.PGobject pgobj]
(let [type (.getType pgobj)
value (.getValue pgobj)]
(case type
"json" (cheshire.core/parse-string value true)
"jsonb" (cheshire.core/parse-string value true)
"citext" (str value)
value)))
(extend-protocol next.jdbc.result-set/ReadableColumn
@dvliman
dvliman / auth-middleware.clj
Created July 22, 2020 17:41
buddy auth access rules snippet
;; File: src/some_app/middleware.clj
(defn open-gates [request]
true)
(def rules [{:pattern #"^/admin.*"
:handler admin-access
:redirect "/notauthorized"},
{:pattern #"^\/vclass.*"
:handler user-access
:redirect "/notauthorized"},
{:pattern #"^\/api.*"
@dvliman
dvliman / future-utils.clj
Created July 15, 2020 01:28
dpsutton's snippet
(defn ->Function
[f]
(reify java.util.function.Function
(apply [_ obj] (f obj))))
(defn future-map
[cf f]
(.thenApply cf (->Function f)))
(defn future->ch
([cf]
(future->ch cf (async/chan 1) true))
@dvliman
dvliman / cheshire.clj
Created July 11, 2020 03:04
cheshire serialize org.postgresql.geometric PGpoint
(ns plokal.cheshire
(:require [cheshire.generate :refer [add-encoder]]
[cheshire.core :as json])
(:import [com.fasterxml.jackson.core JsonGenerator]
(org.postgresql.geometric PGpoint)))
(add-encoder
PGpoint
(fn [^PGpoint data ^JsonGenerator jsonGenerator]
(.writeString jsonGenerator (json/generate-string {:type :Point
go env
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCACHE="/Users/dv/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dv/go"
interview-mind-map
@dvliman
dvliman / concurrency-models
Created April 22, 2020 20:08
concurrency-models
concurrency-models

Keybase proof

I hereby claim:

  • I am dvliman on github.
  • I am dvliman (https://keybase.io/dvliman) on keybase.
  • I have a public key ASBe4DkFe9qsB1j_Dc89k_Vd2euOfMD-Qz4FXTtbNRwTtwo

To claim this, I am signing this object:

@dvliman
dvliman / spike-day-02-03-20.md
Created February 9, 2020 20:46 — forked from cldwalker/spike-day-02-03-20.md
GraalVM dive in Clojure at work

Spike

I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.

GraalVM Build Tools