Amazonica and s3 This was not super obvious, because this example uses a java.io.ByteArrayInputStream with the the :input-stream parameter of the put-object function But in my mind this feels more like an output stream since we’re writing. but maybe this is because we’re reading from the payload . (require ['amazonica.aws.s3 :as 'ss3]) (defn put-s3-obj [bucket-name s3key content] (let [payload (.getBytes content "UTF-8") input-stream (java.io.ByteArrayInputStream. payload)] (ss3/put-object :bucket-name bucket-name :key s3key :input-stream input-stream ; :metadata {:server-side-encryption "AES256"} ;?...
Handies
logging, https://github.com/futurice/timbre ; require... [taoensso.timbre :as log] ; i have ended up using it like this, in a let, with fake variables, (let [ var1 (myfunc "blah") fake1 (log/info (str "var1: " var1))] () ; do stuff)
I am used to python’s zip zip([1, 2, 3], ['a', 'b', 'c']) # [(1, 'a'), (2, 'b'), (3, 'c')] Interleaving and partitioning can do the same thing From stackoverflow , below, This is so clever … (partition 2 (interleave '(1 2 3) '(4 5 6))) ; => ((1 4) (2 5) (3 6)) ; or more generally (defn zip [& colls] (partition (count colls) (apply interleave colls))) (zip '( 1 2 3) '(4 5 6)) ;=> ((1 4) (2 5) (3 6)) (zip '( 1 2 3) '(4 5 6) '(2 4 8)) ;=> ((1 4 2) (2 5 4) (3 6 8)) This was also a cool solution From here user=> (map vector [1 2 3] [4 5 6]) ([1 4] [2 5] [3 6]) user=>
? If on a repl, but wanting to simulate a namespace ns in a project file using discussion in https://www.braveclojure.com/organization/#Anchor-3 … (in-ns 'foo.my-test) hmm I thought that would give me access to the names in that namespace, but in my project, that didnt work… My namespace in .. has (ns foo.my-test (:require [org.httpkit.client :as http] [org.httpkit.fake])) and when i tried … user=> (in-ns 'foo.my-test) #object[clojure.lang.Namespace 0x37b2f7ef "foo.my-test"] foo.my-test=> (org.httpkit.fake/with-fake-http ["http://google.com/" "faked" #_=> "http://flickr....
from clojure for machine learnings.. (defn plot-points "plots sample points of a solution s" [s] (let [X (concat (:hidden s) (:observed s)) Y (concat (:hidden-values s) (:observed-values s))] (view ; NOTE save instead of view can save to a file. (add-points (xy-plot X Y) (:observed s) (:observed-values s))))) ; namespace... ; [incanter "1.5.4"] (ns my-namespace (:use [incanter.charts :only [xy-plot add-points]] [incanter.core :only [view]]) (:require [clojure.core.matrix.operators :as M] [clatrix.core :as cl])) (ns my-namespace (:use clojure....