Skip to content

Instantly share code, notes, and snippets.

@phrohdoh
Last active May 26, 2021
Embed
What would you like to do?
assorted clojure snippets
;; -----------------------------------------------------------------------------
(require '[clojure.spec.alpha :as spec]
#_'[clojure.string :as str]
#_'[clojure.edn :as edn]
#_'[clojure.java.io :as io]
;; non-stdlib deps
'[clojure.spec.gen.alpha :as spec-gen] ;; org.clojure/test.check 1.1.0
'[clojure.data.json :as json] ;; org.clojure/data.json 2.3.1
#_'[datascript.core :as ds] ;; datascript 1.1.0
#_'[datascript.transit :as dsts]) ;; datascript-transit 0.3.0
;; -----------------------------------------------------------------------------
;; -----------------------------------------------------------------------------
#_#_
;; [datascript "1.1.0"]
;; [datascript-transit "0.3.0"]
(require '[datascript.transit :as t])
(let [db-str (slurp "/full/path/to/your/index.transit")
db (datascript.transit/read-transit-str db-str)]
(datascript.core/datoms db :eavt))
;; -----------------------------------------------------------------------------
;; -----------------------------------------------------------------------------
#_#_
(defn load-edn [source]
(try
(with-open [r (clojure.java.io/reader source)]
(clojure.edn/read (java.io.PushbackReader. r)))
(catch java.io.IOException e
(printf "couldn't open '%s': %s\n" source (.getMessage e)))
(catch RuntimeException e
(printf "error parsing edn file '%s': %s\n" source (.getMessage e)))))
(load-edn "/workspaces/ubdgt-clj/resources/ynab-export.edn")
;; => {"data" {"budget" {"transactions" [{"id" "some-txn-id"}]}}}
;; -----------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment