An animated cheatsheet for smartparens using the example configuration specified here by the smartparens author. Inspired by this tutorial for paredit.
C-M-f | sp-forward-sexp |
C-M-b | sp-backward-sexp |
<artifacts_info> | |
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity. | |
# Good artifacts are... | |
- Substantial content (>15 lines) | |
- Content that the user is likely to modify, iterate on, or take ownership of | |
- Self-contained, complex content that can be understood on its own, without context from the conversation | |
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations) | |
- Content likely to be referenced or reused multiple times |
(ns complex-business-process-example-missionary | |
"A stupid example of a more complex business process to implement as a flowchart." | |
(:require [missionary.core :as m]) | |
(:import missionary.Cancelled)) | |
;;;; Config | |
(def config | |
"When set to :test will trigger the not-boosted branch which won't write to db. | |
When set to :prod will trigger the boosted branch which will try to write to the db." |
;; missionary solution to petrol pump example by Stephen Blackheath and Anthony Jones, ISBN 978-1633430105 | |
;; huanhulan's demo : [live](https://huanhulan.github.io/petrol_pump), [code](https://github.com/huanhulan/petrol_pump) | |
(ns pump | |
(:refer-clojure :exclude [first]) | |
(:require [missionary.core :as m]) | |
(:import missionary.Cancelled)) | |
(defn rising | |
"A transducer that outputs `nil` when the input switches from logical false to logical true." |
(ns asyncawait | |
(:refer-clojure :exclude [await]) | |
(:require [cloroutine.core :refer [cr]])) | |
(defmacro async [& body] | |
`(js/Promise. (fn [s# f#] | |
(spawn (cr {await thunk} | |
(try (s# (do ~@body)) | |
(catch :default e# (f# e#)))))))) |
An animated cheatsheet for smartparens using the example configuration specified here by the smartparens author. Inspired by this tutorial for paredit.
C-M-f | sp-forward-sexp |
C-M-b | sp-backward-sexp |
A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.
How to use:
(defn updated-entity | |
"Updates the given entity if the db has changed since the entity was last pulled." | |
[entity] | |
(let [prev-db (d/entity-db entity) | |
curr-db @conn] | |
(if (identical? prev-db curr-db) | |
entity | |
(d/entity curr-db (:db/id entity))))) | |
(defn qes |
(ns user.defn+spec | |
(:require [clojure.spec :as s])) | |
(defn non-&-sym? [x] (and (symbol? x) (not= '& x))) | |
(s/def ::arglist | |
(s/cat :normal-args (s/* (s/cat :name non-&-sym? | |
:spec-form (s/? (s/cat :- #{:-} | |
:spec ::s/any)))) | |
:varargs (s/? (s/cat :& #{'&} |
(comment ; Fun with transducers, v2 | |
;; Still haven't found a brief + approachable overview of Clojure 1.7's new | |
;; transducers in the particular way I would have preferred myself - so here goes: | |
;;;; Definitions | |
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as: | |
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation | |
;; (The `[]` arity is actually optional; it's only used when calling | |
;; `reduce` w/o an init-accumulator). |