Back
first (clj)
(source)variable
(first coll)
Returns the first item in the collection. Calls seq on its
argument. If coll is nil, returns nil.
Examples
jepsen-io/jepsen
(ns yugabyte.ycql.bank
(:refer-clojure :exclude [test])
(:require [clojure.tools.logging :refer [debug info warn]]
[clojure.core.reducers :as r]
[jepsen.client :as client]
[jepsen.checker :as checker]
[jepsen.generator :as gen]
[jepsen.tests.bank :as bank]
[jepsen.checker.timeline :as timeline]
[knossos.op :as op]
[clojurewerkz.cassaforte.client :as cassandra]
[clojurewerkz.cassaforte.cql :as cql]
[clojurewerkz.cassaforte.query :as q :refer :all]
[yugabyte.ycql.client :as c]))
(c/defclient CQLBank keyspace []
(setup! [this test]
(c/create-transactional-table
conn table-name
(q/if-not-exists)
(q/column-definitions {:id :int
:balance :bigint
:primary-key [:id]}))
(info "Creating accounts")
(c/with-retry
(cql/insert-with-ks conn keyspace table-name
{:id (first (:accounts test))
:balance (:total-amount test)})
(doseq [a (rest (:accounts test))]
(cql/insert conn table-name
{:id a, :balance 0}))))
(info "Populating account" a)
(c/with-retry
(cql/insert-with-ks conn keyspace (str table-name a)
{:id a
:balance (if (= a (first (:accounts test)))
(:total-amount test)
0)}))))
(invoke! [this test op]
(c/with-errors op #{:read}
(case (:f op)
:read
(let [as (shuffle (:accounts test))]
(->> as
(mapv (fn [x]
;; TODO - should be wrapped in a transaction after we
;; support transactions with selects.
(->> (cql/select-with-ks conn keyspace
(str table-name x)
(where [[= :id x]]))
first
:balance)))
(zipmap as)
(assoc op :type :ok, :value)))
replikativ/datahike
(ns datahike.http.writer
"Remote writer implementation for datahike.http.server through datahike.http.client."
(:require [datahike.writer :refer [PWriter create-writer create-database delete-database]]
[datahike.http.client :refer [request-json] :as client]
[datahike.json :as json]
[datahike.tools :as dt :refer [throwable-promise]]
[taoensso.timbre :as log]
[clojure.core.async :refer [promise-chan put!]]))
(defmethod create-database :datahike-server
[& args]
(let [p (throwable-promise)
{:keys [writer] :as config} (first args)]
;; redirect call to remote-peer as writer config
(deliver p (try (->
(request-json :post
"create-database-writer"
writer
(vec (concat [(-> config
(assoc :remote-peer writer)
(dissoc :writer))]
(rest args))))
(dissoc :remote-peer))
(catch Exception e
e)))
p))
(defmethod delete-database :datahike-server
[& args]
(let [p (throwable-promise)
{:keys [writer] :as config} (first args)]
;; redirect call to remote-peer as writer config
(deliver p (try
(-> (request-json :post
"delete-database-writer"
writer
(vec (concat [(-> config
(assoc :remote-peer writer)
(dissoc :writer))]
(rest args))))
(dissoc :remote-peer))
(catch Exception e
e)))
p))
HumbleUI/HumbleUI
(ns examples
(:require
[clojure.core.server :as server]
[examples.7guis-converter]
[examples.align]
[examples.animation]
[examples.backdrop]
[examples.blur]
[examples.bmi-calculator]
[examples.button]
[examples.calculator]
[examples.canvas]
[examples.canvas-shapes]
[examples.checkbox]
[examples.container]
[examples.effects]
[examples.errors]
[examples.event-bubbling]
[examples.framerate]
[examples.grid]
[examples.image-snapshot]
[examples.label]
[examples.oklch]
[examples.paragraph]
[examples.scroll]
[examples.settings]
[examples.slider]
[examples.stack]
[examples.state :as state]
[examples.svg]
[examples.text-field]
[examples.text-field-debug]
[examples.todomvc]
[examples.toggle]
[examples.tooltip]
[examples.tree]
[examples.treemap]
[examples.wordle]
[io.github.humbleui.app :as app]
[io.github.humbleui.debug :as debug]
[io.github.humbleui.paint :as paint]
[io.github.humbleui.window :as window]
[io.github.humbleui.ui :as ui]))
(def border-line
(ui/rect (paint/fill light-grey)
(ui/gap 1 0)))
(def app
(ui/default-theme {}; :font-size 13
; :cap-height 10
; :leading 100
; :fill-text (paint/fill 0xFFCC3333)
; :hui.text-field/fill-text (paint/fill 0xFFCC3333)
(ui/row
(ui/vscrollbar
(ui/column
(for [[name _] (sort-by first examples)]
(ui/clickable
{:on-click (fn [_] (reset! examples.state/*example name))}
(ui/dynamic ctx [selected? (= name @examples.state/*example)
hovered? (:hui/hovered? ctx)]
(let [label (ui/padding 20 10
(ui/label name))]
(cond
selected? (ui/rect (paint/fill 0xFFB2D7FE) label)
hovered? (ui/rect (paint/fill 0xFFE1EFFA) label)
:else label)))))))
border-line
[:stretch 1
(ui/clip
(ui/dynamic _ [name @examples.state/*example]
(examples name)))])))
hraberg/deuce
(ns deuce.emacs.dired
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c]
[clojure.java.io :as io]
[deuce.emacs-lisp.cons :as cons])
(:import [java.io File])
(:refer-clojure :exclude []))
Elements of the attribute list are:
0. t for directory, string (name linked to) for symbolic link, or nil.
1. Number of links to file.
2. File uid as a string or a number. If a string value cannot be
looked up, a numeric value, either an integer or a float, is returned.
3. File gid, likewise.
4. Last access time, as a list of two integers.
First integer has high-order 16 bits of time, second has low 16 bits.
(See a note below about access time on FAT-based filesystems.)
5. Last modification time, likewise. This is the time of the last
change to the file's contents.
6. Last status change time, likewise. This is the time of last change
to the file's attributes: owner and group, access mode bits, etc.
7. Size in bytes.
This is a floating point number if the size is too large for an integer.
8. File modes, as a string of ten letters or dashes as in ls -l.
9. t if file's gid would change if file were deleted and recreated.
10. inode number. If it is larger than what an Emacs integer can hold,
this is of the form (HIGH . LOW): first the high bits, then the low 16 bits.
If even HIGH is too large for an Emacs integer, this is instead of the form
(HIGH MIDDLE . LOW): first the high bits, then the middle 24 bits,
and finally the low 16 bits.
11. Filesystem device number. If it is larger than what the Emacs
integer can hold, this is a cons cell, similar to the inode number.
(defun file-attributes-lessp (f1 f2)
"Return t if first arg file attributes list is less than second.
Comparison is in lexicographic order and case is significant."
)
hraberg/deuce
(ns deuce.emacs.bytecode
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c])
(:refer-clojure :exclude []))
(defun byte-code (bytestr vector maxdepth)
"Function used internally in byte-compiled code.
The first argument, BYTESTR, is a string of byte code;
the second, VECTOR, a vector of constants;
the third, MAXDEPTH, the maximum stack depth used in this function.
If the third argument is incorrect, Emacs may crash."
)