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
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE NoStarIsType #-} | |
{-# LANGUAGE PatternSynonyms #-} |
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
(defmulti transmogrify | |
"Rewrites the last form of a thread-last to use transducer (if possible)." | |
(fn [f xform src & args] f)) | |
(defmacro transmogrify->> | |
"Like ->> but uses transducers" | |
([x] x) | |
([src & xs] | |
(let [end (last xs) | |
xforms (butlast xs) |
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- send-udp [s port] | |
(with-open [socket (java.net.DatagramSocket.)] | |
(let [group (java.net.InetAddress/getByName "localhost") | |
bytes (.getBytes s) | |
packet (java.net.DatagramPacket. bytes (count bytes) group port)] | |
(.send socket packet) | |
(.close socket)))) | |
(deftask anybar [p port VAL int "AnyBar port"] | |
(let [port (or port 1738)] |
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
(set-env! :dependencies '[[leiningen-core "2.5.0"]]) | |
(use 'leiningen.core.project) | |
(eval (read-string (slurp "project.clj"))) | |
(set-env! | |
:source-paths (:source-paths project) | |
:resource-paths (:resource-paths project) | |
:dependencies (:dependencies project)) | |
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 history | |
"Light wrappers and utils for js/history") | |
(defn back! [] (.back js/history)) | |
(defn forward! [] (.forward js/history)) | |
(defn go! [idx] (.go js/history idx)) | |
(defn replace-state! |
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 with-local-redefs-fn | |
[a-var its-new-value func] | |
(cast clojure.lang.IFn @a-var) | |
(alter-meta! a-var | |
(fn [m] | |
(if (::scope-count m) | |
(update-in m [::scope-count] inc) | |
(assoc m | |
::scope-count 1 | |
::thread-local-var (doto (clojure.lang.Var/create @a-var) |