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
;; shadow-cljs.edn: {:dependencies [[org.clojure/test.check "1.1.0"]]} | |
;; npm i shadow-cljs | |
;; cider-jack-in-cljs | |
;; shadow | |
;; node-repl | |
foo> (require '[clojure.spec.test.alpha :as spec]) | |
nil | |
foo> (spec/check) |
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
;; use a heap to keep only the max N (here 10) items in memory at a time. imagine reducing over a | |
;; quite large result set. don't want to realize it all, sort, and then take N. Just keep discarding | |
;; compared to our heap's min item. | |
(let [threshold 10 | |
cmp (reify java.util.Comparator | |
(compare [_ x y] | |
;; score is second so want to compare [score item] | |
(compare (vec (reverse x)) (vec (reverse y))))) | |
xf (comp (map (fn [{:keys [name]}] [name (count 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
(require '[clojure.string :as str]) | |
(require '[clojure.core.server :as server]) | |
#_(peek (str/split (str *ns*) #"\.")) ; foo.bar.quux> is just displayed as quux> | |
(clojure.main/repl | |
;; keep prompts shorter | |
:prompt (fn [] (printf "%s=> " (peek (str/split (str *ns*) #"\.")))) | |
;; allow easily ending this sub repl watching for :repl/quit | |
:read server/repl-read) | |
;; fantastic reveal |
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 dev.nocommit.pprint-middleware | |
(:require [honeysql.core :as hsql] | |
[sql-honey.core :as sqlhoney] | |
[metabase.models.database :refer [Database]] | |
[clojure.string :as str]) | |
(:import org.apache.openjpa.lib.jdbc.SQLFormatter)) | |
(let [formatter (SQLFormatter.)] | |
(println | |
(.prettyPrint formatter "select * from orders"))) |
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
(let [addr (java.net.UnixDomainSocketAddress/of "/tmp/222") | |
sc (doto (java.nio.channels.ServerSocketChannel/open java.net.StandardProtocolFamily/UNIX) | |
(.bind addr))] | |
(while true | |
(let [c (.accept sc)] | |
(future | |
(let [in (java.nio.channels.Channels/newInputStream c) | |
out (java.nio.channels.Channels/newOutputStream c)] | |
(binding [*in* (clojure.lang.LineNumberingPushbackReader. | |
(clojure.java.io/reader in)) |
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
--- sdw_500.java 2023-04-14 17:55:38 | |
+++ sdw_523.java 2023-04-14 17:56:20 | |
@@ -32,17 +32,18 @@ | |
import java.nio.charset.StandardCharsets; | |
import java.util.Iterator; | |
+import org.apache.logging.log4j.LogManager; | |
+import org.apache.logging.log4j.Logger; | |
import org.apache.poi.ss.usermodel.Cell; | |
import org.apache.poi.ss.usermodel.CellStyle; |
OlderNewer