Skip to content

Instantly share code, notes, and snippets.

View build.boot
(set-env!
:resource-paths #{"resources"}
:dependencies '[[adzerk/bootlaces "0.1.10" :scope "test"]
[cljsjs/boot-cljsjs "0.5.0" :scope "test"]])
(require '[adzerk.bootlaces :refer :all]
'[cljsjs.boot-cljsjs.packaging :refer :all])
(def +version+ "1.0.2")
(bootlaces! +version+)
View build.boot
(set-env!
:source-paths #{"src" "test"}
:resource-paths #{"src" "test" "sass"}
:wagons '[[s3-wagon-private "1.1.2"]]
:repositories [["clojars" "http://clojars.org/repo/"]
["maven-central" "http://repo1.maven.org/maven2/"]
["releases" {:url "http://archiva:8080/repository/internal"
:username (System/getenv "ARCHIVA_USERNAME")
:password (System/getenv "ARCHIVA_PASSWORD")}]
["my.datomic.com" {:url "https://my.datomic.com/repo"
View built.boot
(deftask add-webjar
"Adds a webjar asset. Example: (add-webjar :jar 'org.webjars.bower/jquery :name \"jquery\")"
[j jar sym "The jar"
n name str "The name"]
(comp
(sift :add-jar {jar #"^META-INF/resources/webjars"})
(sift :move {(java.util.regex.Pattern/compile (str "^META-INF/resources/webjars/" name "/[^/]*/dist/")) (str name "-")})))
@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)))
@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 / 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 / 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 / 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
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 / 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
You can’t perform that action at this time.