list tables, first get the faraday class thing ready. boot.user=> (use '[taoensso.faraday :as dynamo]) with a client-config hash defined in a separate clj file, here one/dynamo.clj is my file. (def client-config (if (:development env) {:access-key "OMGDEVELOPMENT" :secret-key "I_SHOULD_KEEP_THIS_SECRET!" ; Point the configuration at the DynamoDB Local :endpoint "http://localhost:8000"} {:endpoint "http://dynamodb.us-east-1.amazonaws.com"} ) ) and use list-tables from the module/class thing, boot.user=> (use '[one.dynamo :as db]) ; `one/dynamo.clj` boot.user=> (dynamo/list-tables db/client-config) (:primes :projects :times) create table to get this env part to work, I didnt see any way to set the env vars in clojure, so I just set them on my shell,...
Handies
read (use 'clojure.java.io) (with-open [rdr (reader "/tmp/test.txt")] (doseq [line (line-seq rdr)] (println line))) write (use 'clojure.java.io) (with-open [wrtr (writer "/tmp/test.txt")] (.write wrtr "Line to be written"))
sleeping… (Thread/sleep 4000) simple multithreading , from the Brave clojure book (future (Thread/sleep 4000) (println "I'll print after 4 seconds")) (println "I'll print immediately") hmm this is weird. so dereferencing the future blocks? (defn fight-crime [] (let [] (println "hi") (Thread/sleep 2000) (println "ho") (Thread/sleep 1000) (println "yo") 5 )) (let [result (future (fight-crime))] (println "@: " @result) (println "snore. " ) (println "@: " @result) (Thread/sleep 1000) (println "@: " @result) ) Ah ok, but you can stop waiting....
test http-kit timeout.. look at result for a timeout 1ms.. (require ['org.httpkit.client :as 'http]) (let [options {:timeout 1} url "http://yahoo.com" ] (def vout @(http/get url options))) ==> user=> (keys vout) (:opts :error) user=> vout {:opts {:timeout 1, :method :get, :url "http://yahoo.com"}, :error #error { :cause "read timeout: 1ms" :via [{:type org.httpkit.client.TimeoutException :message "read timeout: 1ms" :at [org.httpkit.client.HttpClient clearTimeout "HttpClient.java" 82]}] :trace [[org.httpkit.client.HttpClient clearTimeout "HttpClient.java" 82] [org.httpkit.client.HttpClient run "HttpClient.java" 433] [java.lang.Thread run "Thread....
class cast exception clojure.lang.LazySeq cannot be cast to clojure.lang.IFn => some code is expecting a function, but is getting a LazySeq.