hard sell intro key points we know clojure let's leverage that ie functions. ideally pure ones across the repos, we should follow conventions unless there's a good reason not to what problems are there? duplicated code every project has some about of setup boilerplate
This file contains hidden or 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 com.widdindustries.timelines | |
"create timelines which are (possibly infinite) sequences of maps with a ::time key. | |
Multiple timelines can be merged into a single timeline | |
Zero dependency - BYO time lib | |
Demo in comment at the end | |
") |
This file contains hidden or 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 streaming | |
"read-write large json arrays with jsonista - techniques from | |
https://cassiomolin.com/2019/08/19/combining-jackson-streaming-api-with-objectmapper-for-parsing-json/ | |
comment at end shows running/testing code" | |
(:require [jsonista.core :as j]) | |
(:import (com.fasterxml.jackson.databind ObjectMapper) | |
(com.fasterxml.jackson.core JsonToken JsonGenerator JsonParser) | |
(java.io OutputStream ByteArrayOutputStream ByteArrayInputStream InputStream))) |
This file contains hidden or 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 com-widdindustries-statsatom | |
"A drop-in replacement for clojure.core/atom | |
The difference is that this record the following stats, held in the atom's metadata: | |
- number of times updated via swap!/swap-vals! and | |
- number of attempts made to do those updates | |
Clearly these stats themselves need to be atomically updated so there's some overhead added there. | |
" | |
(:refer-clojure :exclude [atom]) |
This file contains hidden or 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 ftp-client | |
(:require | |
[clojure.java.io :as io] | |
[clojure.tools.logging :as log] | |
[miner.ftp :as ftp]) | |
(:import [java.nio.file Path Paths Files FileSystem FileSystems] | |
[java.nio.file.attribute FileAttribute] | |
[java.io File])) | |
(defn remove! |
This file contains hidden or 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 corr.core | |
(:require [medley.core :as m])) | |
(defn index-by [f coll] | |
(->> coll | |
(group-by f) | |
(m/map-vals (fn [xs] | |
(assert (= 1 (count (take 2 xs)))) | |
(first xs))))) |
This file contains hidden or 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 tidy-requires) | |
(defn tidy-requires [[ _ & requires]] | |
(cons :require (sort-by first requires))) | |
(comment | |
(tidy-requires '(:require [foo] | |
[bar] )) | |
This file contains hidden or 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
;local date to native date (js/Date or java.util.Date.) | |
(-> d | |
(cljc.java-time.local-date/at-start-of-day (t/zone "UTC")) | |
(t/inst)) | |
; native date (js/Date or java.util.Date.) to local date | |
(-> (java.util.Date.) | |
t/instant | |
(cljc.java-time.zoned-date-time/of-instant (t/zone "UTC")) | |
t/date) |
This file contains hidden or 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 transducers) | |
;;;;; simplified traditional impls | |
(defn mymap [f coll] | |
(reduce | |
(fn [acc n] | |
(conj acc (f n))) | |
[] | |
coll)) |
This file contains hidden or 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 deps | |
"use https://github.com/alexander-yakushev/ns-graph | |
to create a function that returns all transitive dependencies of a namespace. | |
handy if you're trying to pull a ns out of a project | |
" | |
(:require [ns-graph.core :as nsg] | |
[clojure.java.io :as io])) |