Skip to content

Instantly share code, notes, and snippets.

@kennyjwilli
kennyjwilli / api-gateway.clj
Created Jun 15, 2020
Code to call API Gateway using utilities copied from Cognitect's aws-api
View api-gateway.clj
(ns cs.aws-api.api-gateway
(:require
[cognitect.aws.credentials :as aws.credentials]
[cognitect.aws.client.shared :as aws.shared]
[cs.aws-api.signers :as signers]
[java-http-clj.core :as http])
(:import (java.net URI)
(java.util Date)
(java.text SimpleDateFormat)))
@kennyjwilli
kennyjwilli / defspec-test.clj
Created Nov 5, 2016
clojure.spec.test integration with clojure.test
View defspec-test.clj
(defmacro defspec-test
([name sym-or-syms] `(defspec-test ~name ~sym-or-syms nil))
([name sym-or-syms opts]
(when t/*load-tests*
`(def ~(vary-meta name assoc :test `(fn []
(let [check-results# (clojure.spec.test/check ~sym-or-syms ~opts)
checks-passed?# (every? nil? (map :failure check-results#))]
(if checks-passed?#
(t/do-report {:type :pass
:message (str "Generative tests pass for "
@kennyjwilli
kennyjwilli / README.md
Last active Nov 9, 2018
Delete leftover Datomic resources
View README.md

Delete Leftover Datomic Cloud Resources

If you delete a Datomic Cloud system, it will leave some resources in AWS. To entirely delete all resources created by Datomic Cloud, you must follow these steps. Because we love automation, this script performs all these steps for you so you don't need to navigate the AWS Console UI.

Prerequisites

@kennyjwilli
kennyjwilli / maven-to-deps.clj
Created Jun 22, 2018
Maven to deps.edn converter
View maven-to-deps.clj
(defn transform-deps
[deps]
(binding [*print-namespace-maps* false]
(clojure.pprint/pprint
(reduce (fn [deps-edn [id version & opts]]
(let [opts (apply hash-map opts)]
(if (= "test" (:scope opts))
deps-edn
(assoc deps-edn
id (merge {:mvn/version version}
@kennyjwilli
kennyjwilli / nodejs_cljs_repl.clj
Created Sep 1, 2017
Start a NodeJS REPL in Boot after running boot watch cljs-repl
View nodejs_cljs_repl.clj
(require 'cemerick.piggieback)
=> nil
(require '[cljs.repl.node])
=> nil
(cemerick.piggieback/cljs-repl (cljs.repl.node/repl-env))
ClojureScript Node.js REPL server listening on 56999
To quit, type: :cljs/quit
=> nil
(+ 1 1)
=> 2
View precept_example.clj
(rules/rule logging-in
[[_ :logging-in? true]]
[[_ :email ?email]]
[[_ :password ?password]]
=>
(do-login ?email ?password
(fn [[ok? response]]
(println "login response" (pr-str response))
(precept/then (into
[[:global :logged-in? true]
@kennyjwilli
kennyjwilli / patch.cljs
Created Nov 17, 2016
Optimized js->clj implementation by Darrick Wiebe
View patch.cljs
; Optimized js->clj implementation by Darrick Wiebe (http://dev.clojure.org/jira/browse/CLJS-844)
; https://github.com/asciinema/asciinema-player/blob/master/src/asciinema/player/patch.cljs
(defn js->clj
([x] (js->clj x :keywordize-keys false))
([x & opts]
(cond
(satisfies? IEncodeClojure x)
(-js->clj x (apply array-map opts))
(seq opts)
(let [{:keys [keywordize-keys]} opts
@kennyjwilli
kennyjwilli / boot-update-file.clj
Last active Sep 9, 2016
boot update file task
View boot-update-file.clj
(ns myns.core
{:boot/export-tasks true}
(:require
[boot.core :as core]
[clojure.edn :as edn]
[clojure.java.io :as io]))
(core/deftask update-file
"Updates files whose path matches `match-files` with the value returned from `expr`.
`expr` is a function that takes the parsed content of the file and returns the new
@kennyjwilli
kennyjwilli / reagent_datascript2.cljs
Created Dec 4, 2015 — forked from allgress/reagent_datascript2.cljs
Use experimental fork of DataScript from https://github.com/allgress/datascript to handle undo and per-query subscriptions
View reagent_datascript2.cljs
;;; Use experimental fork of DataScript from https://github.com/allgress/datascript to handle undo and per-query subscriptions
(ns reagent-test.core
(:require [reagent.core :as reagent :refer [atom]]
[datascript :as d]
[cljs-uuid-utils :as uuid]))
(enable-console-print!)
(defn bind
([conn q]
@kennyjwilli
kennyjwilli / reagent_datascript.cljs
Created Dec 4, 2015 — forked from allgress/reagent_datascript.cljs
Test use of DataScript for state management of Reagent views.
View reagent_datascript.cljs
(ns reagent-test.core
(:require [reagent.core :as reagent :refer [atom]]
[datascript :as d]
[cljs-uuid-utils :as uuid]))
(enable-console-print!)
(defn bind
([conn q]
(bind conn q (atom nil)))
You can’t perform that action at this time.