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
;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
(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
(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
;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
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] |
NewerOlder