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
engage-rackspace.groups.core=> (pallet.api/converge (assoc eng-web-test :count 1) :compute rs :user midverse-user) | |
12:57:02.282 [operate-21] INFO pallet.ssh.execute - 23.253.42.140 22 os: infer-os: | |
12:57:14.982 [operate-21] ERROR pallet.action-plan - Exception in execute-action-map | |
clojure.lang.ExceptionInfo: SSH connect: server 23.253.42.140 port 22 user null password null pk-path /Users/raspasov/.ssh/midverse pk null | |
at clojure.core$ex_info.invoke(core.clj:4403) ~[clojure-1.6.0.jar:na] | |
at pallet.ssh.transport$connect_ssh_session.invoke(transport.clj:117) ~[na:na] | |
at pallet.ssh.transport$attempt_connect.invoke(transport.clj:153) ~[na:na] | |
at pallet.ssh.transport$connect$fn__8485.invoke(transport.clj:172) ~[na:na] | |
at pallet.ssh.transport$connect.invoke(transport.clj:171) ~[na:na] | |
at pallet.transport.ssh$lookup_or_create_state.invoke(ssh.clj:53) ~[na:na] |
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
;ADD TO YOUR project.clj: | |
[org.clojure/java.jdbc "0.3.4"] | |
[mysql/mysql-connector-java "5.1.31"] | |
[com.jolbox/bonecp "0.8.0.RELEASE"] | |
;https://github.com/ptaoussanis/timbre for error logging, make sure to set your error log file | |
[com.taoensso/timbre "3.2.1"] | |
;SOURCE STARTS BELOW | |
(ns your-project.mysql-lib | |
(:require [clojure.java.jdbc :as db-adapter] |
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 string-contains? | |
"Searches a string s for any number of sub-strings, returns true on the first found, false otherwise" | |
[s sub & subs] | |
(if subs | |
(loop [subs (cons sub subs)] | |
(if-not (empty? subs) | |
(if-let [has-sub? (.contains s (first subs))] | |
has-sub? | |
(recur (rest subs))) | |
false)) |
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 new-ops-collector | |
"Create a new op collector | |
The collector is a vector of vectors, each internal vector | |
is a tuple of f and vector-of-params, i.e. [f vector-of-params]. | |
Later on we execute all the ops in a single transaction via (execute-ops collector) | |
Example structure: [[f [param1 param2 etc]] etc ] " | |
[] | |
(atom [])) | |
(defn add-op |
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
;create our publisher | |
(def pub-ch (chan)) | |
(def publication (pub pub-ch #(:topic %))) | |
;sub chans | |
(def sub-1 (chan)) | |
(def sub-2 (chan)) | |
;subscribe subs to publisher | |
(sub publication "clojure" sub-1) |
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
public class SystemClock { | |
public static long lastTime = 0; | |
/** | |
* Returns a strictly increasing time in number of 100 ns that passed since Unix Epoch. | |
*/ | |
public static synchronized long getTime() { | |
long time = System.currentTimeMillis() * 10L*1000L; | |
if (time <= lastTime) { |
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
;looking to transform: | |
(def x ([14227624954630003 3] [14227624954630004 4] [14227624954630005 5] [14227624954630006 6])) | |
;... into: | |
[[14227624954630003 14227624954630004 14227624954630005 14227624954630006] [3 4 5 6]] | |
;anything more idiomatic than: | |
(reduce (fn [result new] | |
[(conj (nth result 0) (nth new 0)) | |
(conj (nth result 1) (nth new 1))]) [[] []] x) | |
;? |
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 my-project.test-core-async | |
(:require [clojure.core.async :refer [chan thread sliding-buffer timeout go <! <!! >!! >! go-loop put! thread alts!! alts! dropping-buffer pipeline-blocking]])) | |
(def events-ch (chan 1000)) | |
;alternatively, try a sliding buffer if events can't be processed fast enough | |
;in GUI one **usually** cares about latest instead of *all* events | |
;Defaults to buffer size to 1000, that can be tuned based on use case | |
;(def events-ch (chan (sliding-buffer 1000))) | |
(defn start-go-loop |
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
;add (:require [clojure.core.async :refer [chan close! go >! <! <!! >!! go-loop put! thread alts! alts!! timeout pipeline pipeline-blocking pipeline-async]]) | |
;chans | |
(def to-ch (chan)) | |
(def from-ch (chan)) | |
;data looks like {url some-data, etc} | |
(def my-map (atom {})) | |
(defn fetch-from-url [{:keys [url]}] |
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 cloud-monkey.env | |
(:require [environ.core :as environ])) | |
(defonce env environ/env) | |
(defn merge-with-env! [a-map] | |
(alter-var-root #'env (fn [x] (merge x a-map)))) |
OlderNewer