;; (cond-let | |
;; (odd? x) [x n] (inc x) | |
;; (< n 10) [y (inc n)] 10 | |
;; :else n)) | |
;; we want the above to yield | |
;; (let [x n] | |
;; (if (odd? x) | |
;; (inc x) |
(defn debounce [in ms] | |
(let [out (chan)] | |
(go-loop [last-val nil] | |
(let [val (if (nil? last-val) (<! in) last-val) | |
timer (timeout ms) | |
[new-val ch] (alts! [in timer])] | |
(condp = ch | |
timer (do (>! out val) (recur nil)) | |
in (recur new-val)))) | |
out)) |
;; The deps.edn file describes the information needed to build a classpath. | |
;; | |
;; When using the `clojure` or `clj` script, there are several deps.edn files | |
;; that are combined: | |
;; - install-level | |
;; - user level (this file) | |
;; - project level (current directory when invoked) | |
;; | |
;; For all attributes other than :paths, these config files are merged left to right. | |
;; Only the last :paths is kept and others are dropped. |
(defn stateful-map | |
"Returns a stateful transducer similar to `clojure.core/map-indexed` that | |
transforms each item with `(f state <the item>)` where `state` is built by | |
applying `state-building-fn` to the previous state (starting with `init`) and | |
the transformed item. | |
Ex., re-implementing map-indexed: | |
```clojure | |
(sequence (stateful-map vector (fn build-state [idx _] (if idx (inc idx) 5))) \"abc\") | |
; => ([nil \\a] [5 \\b] [6 \\c]) |
;; A macro to create a decorator (wrapper) for a objects implementing a Java interface | |
;; Disclaimer: The code most certainly is not perfect and does not handle some corner cases | |
;; License: The Unlicense http://unlicense.org/ | |
(require '[clojure.string :as str]) | |
(defn type->tag [parameter-type] | |
(let [array? (-> parameter-type name (str/ends-with? "<>")) | |
primitive? '#{int long float double short boolean byte char} | |
type (if array? | |
(-> parameter-type name (str/replace #"<>$" "") symbol) |
A gist containing a problem example and different implementations based on what is being discussed at How are clojurians handling control flow on their projects?.
Feel free to leave a comment and feedback is welcome 😃
- Bult-in exceptions in a thread macro
- didibus'
trylet
macro
(ns complex-business-process-example | |
"A stupid example of a more complex business process to implement as a flowchart.") | |
;;;; 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." | |
{:env :prod}) |
(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." |
pandora’s vox: on community in cyberspace
by humdog (1994)
when i went into cyberspace i went into it thinking that it was a place like any other place and that it would be a human interaction like any other human interaction. i was wrong when i thought that. it was a terrible mistake.
the very first understanding that i had that it was not a place like any place and that the interaction would be different was when people began to talk to me as though i were a man. when they wrote about me in the third person, they would say “he.” it interested me to have people think i was “he” instead of “she” and so at first i did not say anything. i grinned and let them think i was “he.” this went on for a little while and it was fun but after a while i was uncomfortable. finally i said unto them that i, humdog, was a woman and not a man. this surprised them. at that moment i realized that the dissolution of gender-category was something that was happening everywhere, and perhaps it was only just very obvious on the ne