Back
random-uuid (clj)
(source)function
(random-uuid)
Returns a pseudo-randomly generated java.util.UUID instance (i.e. type 4).
See: https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html#randomUUID--
Examples
fulcrologic/fulcro
(ns fulcro-todomvc.server
(:require
[com.fulcrologic.fulcro.mutations :as m :refer [defmutation]]
[clojure.core.async :as async]
[com.wsscode.pathom.core :as p]
[com.wsscode.pathom.connect :as pc]
[taoensso.timbre :as log]))
(pc/defmutation todo-new-item [env {:keys [id list-id text]}]
{::pc/sym `fulcro-todomvc.api/todo-new-item
::pc/params [:list-id :id :text]
::pc/output [:item/id]}
(log/info "New item on server")
(let [new-id (random-uuid)]
(swap! item-db assoc new-id {:item/id new-id :item/label text :item/complete false})
{:tempids {id new-id}
:item/id new-id}))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
"Type annotations for the base Clojure distribution."
#?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
(:require [clojure.core :as cc]
[typed.clojure :as t]
#?(:clj [typed.ann-macros.clojure :as macros])
#?(:clj typed.ann.clojure.jvm) ;; jvm annotations
#?(:clj clojure.core.typed))
#?(:clj
(:import (clojure.lang PersistentHashSet PersistentList
APersistentMap #_IPersistentCollection
#_ITransientSet
IRef)
(java.util Comparator Collection))))
cc/seqable? (t/Pred t/AnySeqable)
cc/indexed? (t/Pred (t/Indexed t/Any))
cc/inst-ms [:-> t/Int]
cc/inst? (t/Pred cc/Inst)
cc/uuid? (t/Pred t/UUID)
cc/random-uuid [:-> t/UUID]
cc/parse-uuid [t/Str :-> (t/Option t/UUID)]
cc/uri? (t/Pred t/URI)
cc/tagged-literal? (t/Pred clojure.lang.TaggedLiteral)
cc/reader-conditional? (t/Pred clojure.lang.ReaderConditional)
zhaojw/closerve
(ns closerve.snippet
(:require [hickory.core :as h]
[clojure.zip :as zip]
[clojure.set :as set]
[clojure.core.async :refer [go close! >!! <! >! sliding-buffer chan]])
(:use [clojure.xml]
[clojure.walk]
[clojure.contrib.core]
[hickory zip render]
[ring.util.time :only (format-date)]
[ring.util.codec :as codec]
[closerve state util html wscmd liftutil]))
(register-lift-snippet
"LazyLoad"
[node req page-id lift-instr]
(let [uuid (make-random-uuid)
fastret (assoc-in node [:attrs :id] uuid)
fastret (assoc fastret :content ["Loading..."])]
(go (let [slowret (process-snippets node req page-id)]
(send-cmd-to-page page-id {:act :replaceWith
:selector (str "#" uuid)
:html (hickory-to-html slowret)})))
fastret)
)
(register-lift-snippet
"comet"
[node req page-id lift-instr]
(let [uuid (make-random-uuid)
actor-fn (@name->comet (lift-instr "type"))
comet-ch (chan)
fastret (assoc node [:attrs :id] uuid)]
(swap! page->comet-ch assoc-into-key-values page-id comet-ch)
(if actor-fn (actor-fn comet-ch req page-id uuid))
fastret))
(register-lift-snippet
;let browser run a js query, and send the result back to server
"query.ajax"
[node req page-id lift-instr]
(let [uuid (make-random-uuid)]
(register-call-back-fn page-id uuid
(lift-instr "callback")
{:session-id (-> req :session :session-id)
:req req
:page-id page-id
:uuid uuid}
:pre-proc-fn (fn [cm]
(let [data (:data cm)]
data)))
(send-cmd-to-page page-id {:act :queryEval :code (lift-instr "code") :uuid uuid})
node)
)
babashka/sci.configs
(ns sci.configs.clojure-1-11
(:require [sci.core :as sci]
[sci.impl.utils :refer [clojure-core-ns]]
[clojure.core :as c]))
(def ^:private clojure-core-namespace-extras-1-11
{'abs (sci/copy-var c/abs clojure-core-ns)
'NaN? (sci/copy-var c/NaN? clojure-core-ns)
'infinite? (sci/copy-var c/infinite? clojure-core-ns)
'parse-double (sci/copy-var c/parse-double clojure-core-ns)
'parse-long (sci/copy-var c/parse-long clojure-core-ns)
'parse-boolean (sci/copy-var c/parse-boolean clojure-core-ns)
'parse-uuid (sci/copy-var c/parse-uuid clojure-core-ns)
'random-uuid (sci/copy-var c/random-uuid clojure-core-ns)
'update-keys (sci/copy-var c/update-keys clojure-core-ns)
'update-vals (sci/copy-var c/update-vals clojure-core-ns)
'iteration (sci/copy-var c/iteration clojure-core-ns)})
yetanalytics/datasim
(ns com.yetanalytics.datasim.onyx.scratch
"Scratch ns for playing with onyx"
(:require
[clojure.core.async :as a]
com.yetanalytics.datasim.onyx.main ;; get all boot-up ns stuff
[onyx.plugin.http-output :as http]
[onyx.plugin.core-async :as ap]
[onyx.plugin.seq]
[onyx.api]
[onyx.test-helper :as th]
[com.yetanalytics.datasim.onyx.sim :as dsim]
[com.yetanalytics.datasim.onyx.job :as job]
[com.yetanalytics.datasim.onyx.config :as config]))
(comment
;; Run things in an enclosed environment
(let [id (random-uuid)
{:keys [env-config peer-config]} (-> (config/get-config)
(assoc-in [:env-config :onyx/tenancy-id] id)
(assoc-in [:peer-config :onyx/tenancy-id] id))]
(th/with-test-env
[{:keys [n-peers
env
peer-group
peers]
:as test-env} [;; n-peers
3 ;;
env-config
peer-config
]]
(let [;; Submit the job
submission (onyx.api/submit-job
peer-config
(job/config
{:input-loc "dev-resources/input/mom64.json"
:gen-concurrency 1
:gen-batch-size 10
:post-concurrency 1
:override-max 100
:out-ratio 1
:out-mode :lrs
:lrs {:endpoint "http://localhost:8080/xapi"}}))]