Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns default-maps | |
"Maps with default values, similar to how you can specify default values and blocks to Ruby's Hash. | |
Examples: | |
user> (def b (assoc-default {:foo 34 :bar 34} (fn [_ k] (str k)))) | |
#'user/b | |
user> (get b :foo-bar) | |
\":foo-bar\" | |
user> (def m (assoc-default {:foo 34 :bar 34} 343)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns favila.async-util | |
"Some missing pieces of core.async. | |
as-transducer: Make a transducer function easily without Clojure 1.7. | |
go-pipe: async/pipe, but returns the go-loop. | |
fast-pipeline-blocking: faster than async/pipeline-blocking, but unordered results. | |
blocking-consumer: consume a channel with multiple worker threads." | |
(:require [clojure.core.async :as async | |
:refer [go go-loop <! >! <!! >!! close! take! put! chan]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OUTDIR=. | |
while read -r db ; do | |
while read -r table ; do | |
if [ "$db" == "system" ]; then | |
echo "skip system db" | |
continue 2; |
Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups
command.
- List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe
Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.
- Reset the consumer offset for a topic (preview)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;Montreal Clojure Meetup 2019 | |
;;sources | |
; - https://clojure.org/reference/java_interop | |
; - https://leanpub.com/clojure-java-interop/read_sample | |
; - http://blog.jayfields.com/2011/12/clojure-java-interop.html | |
; - https://stackoverflow.com/questions/2181774/calling-clojure-from-java | |
; - https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.2-200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns scratch) | |
(defn map [f] | |
(fn [xf] | |
(fn | |
([] (xf)) | |
([acc] (xf acc)) | |
([acc itm] | |
(xf acc (f itm)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; inspired by: https://clojuredocs.org/clojure.zip/zipper#example-54d91161e4b081e022073c72 | |
(defn map-zipper | |
[m ref-keys] | |
{:pre [(set? ref-keys)]} | |
(z/zipper | |
(fn is-branch? [x] | |
(let [ret | |
(cond | |
(not (coll? x)) |
The current version of this document is here.
This document contains additional supporting material for the claims in this post (published 1 September 2019), in response to a cease and desist letter from John De Goes that I received on 6 July 2020.
Please see also this post for more information about De Goes deleting the FCoP repository on GitHub shortly before sending the cease and desist letter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cola.core) | |
(def names ["Sheldon" "Leonard" "Penny" "Rajesh" "Howard"]) | |
(defn double-size [[size name]] | |
[(* 2 size) name]) | |
(def group (map vector (repeat 1) names)) | |
(def groups (lazy-cat group (map double-size groups))) |
OlderNewer