This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns metosin.common.edn | |
#+clj | |
(:require [clj-time.format :as f]) | |
#+cljs | |
(:require [cljs-time.format :as f] | |
cljs.reader) | |
#+clj (:import [org.joda.time DateTime LocalDate])) | |
;; | |
;; #DateTime tagging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This buffer is for Clojure experiments and evaluation. | |
;; Press C-j to evaluate the last expression. | |
(fn trapezoid [v] | |
(let [row (fn [v] | |
(-> (vector (first v)) | |
(into (map #(reduce +' %) (partition 2 1 v))) | |
(conj (last v))))] | |
(lazy-seq (cons v (trapezoid (row v)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn inspect | |
"Reflects the members of an object and prints them. Returns the | |
number of members on the object. Constructors are labeled | |
with [ctor], public members are prefixed with +, private members are | |
prefixed with -, and static members are listed as Class/member. | |
Fields are annotated as fieldName : type, functions have a parameter | |
list enclosed in parentheses (param1, param2) followed by an arrow | |
-> and the return type. Varargs have an elipsis following the last | |
param (params...)." | |
[x] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro <!? | |
"Exception-aware parking take. If a Throwable is returned | |
from the channel, it is re-thrown." | |
[c] | |
`(let [v# (<! ~c)] | |
(if (instance? Throwable v#) | |
(throw v#) | |
v#))) | |
(defmacro <!!? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(deftask overwrite | |
[f file VAL str "The path of the file to overwrite" | |
w with VAL str "The file containing the source content"] | |
(with-pre-wrap fs | |
(let [{:keys [file with]} *opts* | |
src-file (tmp-get fs with) | |
out-file (tmp-get fs file)] | |
(-> fs | |
(cp (tmp-file src-file) out-file) | |
commit!)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn show-routes | |
"Prints the application's route table" | |
[] | |
(print-routes routes)) | |
(defn named-route | |
"Finds a route by name" | |
[route-name] | |
(->> routes | |
(filter #(= route-name (:route-name %))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
CHECKOUT=/tmp/clojurescript.git | |
rm -rf $CHECKOUT | |
git clone --bare [email protected]:clojure/clojurescript.git $CHECKOUT >/dev/null 2>&1 | |
pushd $(pwd) > /dev/null | |
cd $CHECKOUT | |
VERSION=$(git describe --abbrev=0 --tags | sed "s/^r//") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns datascript-to-datomic-util | |
(:require [datascript :as d])) | |
;;;; a utility to help with a datomic-datascript roundtrip process involving: | |
;;; 1. export some data from a datomic database and transact into a datascript instance. | |
;;; 2. perform one or more transactions against datascript. | |
;;; 3. transact the sum of all changes made against datascript back into datomic in a single tx | |
;;; this namespace contains two public functions: | |
;;; listen-for-changes: listen to datascript transactions and build up a record of changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def path-element (s/or :key keyword? :index integer?)) | |
(s/def :column/title string?) | |
(s/def :column/spec (s/or :path (s/+ path-element) | |
:path+keys (s/cat :path (s/* path-element) | |
:keys (s/coll-of keyword? [])) | |
:path+fn (s/cat :path (s/* path-element) | |
:fn fn?) | |
:fn fn?)) | |
(s/def ::column (s/keys :req [:column/title :column/spec])) | |
(s/def :grid/title string?) |