Skip to content

Instantly share code, notes, and snippets.

(defn rect [wd ht] {:Shape ::rect :wd wd :ht ht})
(defn circle [radius] {:Shape ::circle :radius radius})
(defn square [wd ht ] {:Shape ::square :wd wd :ht ht})
(defmethod area :default [x] :oops)
(defmethod area ::rect [r]
(* (:wd r) (:ht r)))
(derive ::square ::rect)
(area (rect 10 10))
(defn get-length
[path]
(let [cmd (str
"ffmpeg -i '"
path
"' 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//"
)
output (.start (ProcessBuilder. (into-array ["/bin/bash" "-c" cmd])))
info (slurp (.getInputStream output))]
In [2]: import tensorflow as tf
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-64156d691fe5> in <module>()
----> 1 import tensorflow as tf
/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
(defn _trades-chan
"Open the URL as a stream of trades information. Return a channel of the trades, represented as strings."
[]
(let[session (new-session)
{:keys [url sessionid]} (:stream session)
dump-url (str url "?sessionid=" sessionid "&symbols=mu" )
lines (-> dump-url
(client/get {:as :stream})
:body
io/reader
{:inputs [{:id 1 :headline "YAMBA MALAWI GALA FOR GOOD"},
{:id 2 :headline "ALICE + OLIVIA SUPPORTS GOOD+ IN THE HAMPTONS"},
{:id 3 :headline "GOOP HOSTS IN GOOP HEALTH"}]
:searches [
{:input "GOOD", :output [1,2]},
{:input "GOOP", :output [3]}]
}
@jdkealy
jdkealy / gist:a950be8ff0cdfccda101dcb5158cdbb0
Last active April 2, 2018 17:41
WILDCARD / EVENTS SEARCH
{:inputs [{:id 1 :headline "YAMBA MALAWI GALA FOR GOOD"},
{:id 2 :headline "ALICE + OLIVIA SUPPORTS GOOD+ IN THE HAMPTONS"},
{:id 3 :headline "GOOP HOSTS IN GOOP HEALTH"}
{:id 4 :headline "GOODS FOR GOOD"
:id 5 :headline "ZEBRA FOR BAD"
}]
:searches [
{:input "GOOD", :output [1,2,4]},
{:input "GOOP", :output [3]}]}
; the query
(d/q '[:find ?price ?pt ?type
:in $ $shard ?cid ?type
:where
[$shard ?e :content/collection ?coll]
[$shard ?e :content/price_tier ?pt]
[$shard ?coll :collection/organization ?user]
[$ ?user :user/prices ?p]
[$ ?p :price/price ?price]
individual photos
[2317487, 2317496, 2344921, 2344923, 2344925, 2344926, 2344927, 2344928, 2344929, 2344930, 2344931, 2344932, 2344933, 2344934, 2344935, 2344936, 2344937, 2344938, 2344939, 2344940, 2344941, 2344942, 2344943, 2344944, 2344945, 2344946, 2344947, 2344948, 2345266, 2358213, 2364500, 2364501, 2364502, 2364503, 2364504, 2364505, 2364506, 2364507, 2364508, 2368845, 2368846, 2368848, 2368850, 2380534, 2380535, 2380536, 2380537, 2380538, 2380539, 2380540, 2380541, 2380542, 2380543, 2380544, 2380545, 2380546, 2380547, 2380548, 2380549, 2380550, 2380551, 2380552, 2380553, 2380554, 2380555, 2380556, 2380557, 2380558, 2380559, 2380560, 2380561, 2380562, 2380563, 2380564, 2380565, 2380566, 2380567, 2380568, 2380569, 2380570, 2380571, 2380572, 2380573, 2380574, 2380575, 2380576, 2380577, 2380578, 2380579, 2380580, 2380581, 2380582, 2380583, 2380584, 2380585, 2380586, 2380587, 2380589, 2380590, 2380591, 2380592, 2380593, 2380594, 2380595, 2380596, 2380597, 2380598, 2380599, 2380600, 2380601, 2380602, 23806
(defn concat-memo [current _new]
(let [oldq (:query current)
oldi (:inputs current)
newq (:query _new)
newi (:inputs _new)
_all {:query {:find (if-let [_find (:find newq)]
(vec (concat (:find oldq) _find))
(:find oldq))
:in (if-let [_in (:in newq)]
(vec (concat (:in oldq) _in))
(d/q
'[:find ?u
:where [?u :user/email "jdkealy@gmail.com"]]
(db/_d))
; #{[17592186045908]}
(d/q
'[:find ?entity ?name ?tx ?score
:in $ ?search