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
;; Just some random REPL experiments I wanted to safe in case I want to make | |
;; the mistake of building an SQL query generator. | |
(require '[clojure.string :as string]) | |
(defmulti sql-op type) | |
(defmethod sql-op Long [_] "=") | |
(defmethod sql-op String [_] "=") | |
(defmethod sql-op java.util.List [_] "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
(ns task-web.models.db | |
(:require [clojure.tools.logging :as log] | |
[clojure.java.jdbc :as sql] | |
[clojure.string :as string])) | |
(declare scrub) | |
;;----------------------------------------------------------------------------- | |
;; UTILS | |
;;----------------------------------------------------------------------------- |
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
;; How do you undef / unintern a symbol in Clojure? | |
(ns-unmap 'namespace 'symbol) |
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
bold="\[\033[01m\]" | |
off="\[\033[0m\]" | |
blue="\[\033[0;34m\]" | |
red="\[\033[0;31m\]" | |
light_red="\[\033[1;31m\]" | |
green="\[\033[0;32m\]" | |
lgreen="\[\033[1;32m\]" | |
white="\[\033[1;37m\]" |
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 jmxican.core | |
(:require | |
[clojure.java.jmx :as jmx])) | |
;;----------------------------------------------------------------------------- | |
;; Little ditty to keep the app up and running until | |
;; we get an OS signal to shut down. | |
;;----------------------------------------------------------------------------- | |
(let [lock (promise)] |
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.java.io :as io]) | |
(defn- log-failure | |
"Log something when the agent apparatus itself isn't working." | |
[agent exception] | |
(println "ERROR:" "agent" agent "failed with exception" exception)) | |
(defn- make-agent | |
"Create an agent wrapping applications to a file." | |
[file] |
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
;; | |
;; | |
(defprotocol ITopic | |
(pub! [this value]) | |
(sub! [this subscriber])) | |
(defrecord AgentBasedTopic [agent worker error-handler subscribers] | |
;; | |
;; This version works well enough but doesn't gate as well as a |
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
;; | |
(import [java.util.concurrent ArrayBlockingQueue]) | |
(defprotocol ITopic | |
(pub! [this value]) | |
(sub! [this subscriber])) | |
(defrecord QueueBasedTopic [queue worker error-handler subscribers] | |
;; |
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 telewang.util | |
(:require [clojure.string :as string])) | |
(defn- psql | |
[re sql] | |
(string/replace sql re "?")) | |
(defn- pvec | |
[re sql params] | |
(->> (re-seq re sql) ;; re-seq -> the bee's knees |
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
;; Play around with ZIP file processing, specifically, trying to find | |
;; <redacted>*log* files inside <redacted> support bundles. | |
(import '[java.util.zip ZipFile ZipInputStream] | |
'[java.io FileInputStream ByteArrayOutputStream BufferedReader StringReader]) | |
(defn- mk-lazy-reader | |
"Given our current location in the zip stream, return a | |
lazy reader so that we can get the contents of the zipped | |
entry when we ask for it." |