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 util.redis | |
(:refer-clojure :exclude [memoize]) | |
(:require [taoensso.carmine :as car])) | |
;; boilerplate stuff that is not in Carmine | |
(def ^:dynamic ^:private *pool*) | |
(def ^:dynamic ^:private *spec*) | |
(defmacro with-redis |
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 parse (p/parser parser-options | |
:start [:params? :line*] | |
:start :tag-line | |
:vspace #"[\n\r]+" | |
:params [:vspace :doctype] | |
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-query-results-cursor | |
"Execute a query using a cursor to efficiently handle large data | |
sets. result-fn will be applied to a result set seq." | |
[[sql & params :as sql-params] fetch-size result-fn] | |
(sql/transaction | |
(with-open [stmt (.prepareStatement (sql/connection) sql)] | |
(doseq [[index value] (map vector (iterate inc 1) params)] | |
(.setObject stmt index value)) | |
(.setFetchSize stmt fetch-size) | |
(with-open [rset (.executeQuery stmt)] |
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 groupon.joda-instant-reader | |
(:require [clojure.instant :as i]) | |
(:import org.joda.time.DateTime)) | |
(defmethod print-method org.joda.time.DateTime | |
[^org.joda.time.DateTime d ^java.io.Writer w] | |
(#'i/print-date (java.util.Date. (.getMillis d)) w)) | |
(defmethod print-dup org.joda.time.DateTime |
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 groupon.joda-instant-reader | |
(:require [clojure.instant :as i]) | |
(:import org.joda.time.DateTime)) | |
(defmethod print-method org.joda.time.DateTime | |
[^org.joda.time.DateTime d ^java.io.Writer w] | |
(#'i/print-date (java.util.Date. (.getMillis d)) w)) | |
(defmethod print-dup org.joda.time.DateTime |
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
(in-ns 'user) | |
`inst | |
;; => user/inst | |
`'inst | |
;; => (quote user/inst) | |
`'~'inst | |
;; => (quote inst) |
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
Caused by: java.lang.IllegalArgumentException: No matching ctor found for class kibit.rules.util$compile_rule$fn__2052 | |
at clojure.lang.Reflector.invokeConstructor(Reflector.java:163) | |
at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1053) | |
at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:626) | |
at clojure.lang.LispReader.read(LispReader.java:185) | |
at clojure.lang.RT.readString(RT.java:1738) | |
at kibit.rules.arithmetic__init.__init0(Unknown Source) | |
at kibit.rules.arithmetic__init.<clinit>(Unknown Source) | |
... 138 more |
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
;; specify the print length to be 100 to stop infinite sequences | |
;; killing things. | |
(defun nrepl-limit-print-length () | |
(interactive) | |
(nrepl-send-string-sync "(set! *print-length* 100)" "clojure.core")) | |
(defun nrepl-unlimit-print-length () | |
(interactive) | |
(nrepl-send-string-sync "(set! *print-length* nil)" "clojure.core")) |
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
FQDNLookup true | |
Hostname "localhost" | |
Interval 5 | |
LoadPlugin syslog | |
<Plugin syslog> | |
LogLevel info | |
</Plugin> |
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 debounce | |
([source msecs edge] | |
(debounce (chan) source msecs edge)) | |
([sink source msecs edge] | |
(go (loop [state ::init last nil chans [source]] | |
(let [[_ timer] chans | |
[v c] (alts! chans)] | |
(match [state c edge] | |
[::init source :leading] (do (>! sink v) | |
(recur ::debouncing nil (conj chans (timeout msecs)))) |