I've been working with Apache Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥
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
[Test] | |
public void CursorShouldGetLessOrEqual() { | |
_db = _txn.OpenDatabase(flags: DbFlags.None); | |
var db2 = _txn.OpenDatabase("test_le", | |
DbFlags.Create | DbFlags.IntegerKey); | |
using (var cur = _txn.CreateCursor(db2)) { | |
int[] keys = new int[10000000]; |
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)) |
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 crux-pull | |
(:require | |
[edn-query-language.core :as eql] | |
[crux.api :as crux] | |
[my-app.crux-node :refer [crux-node]])) | |
(defn entity | |
([entity-id] (entity crux-node entity-id)) | |
([crux-node entity-id] | |
(crux/entity (crux/db crux-node) entity-id))) |
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 datascript-crux.pull-api | |
(:require | |
[crux.api :as crux] | |
[datascript.pull-parser :as dpp] | |
[my-app.crux-node :refer [crux-node]]) | |
(:import [datascript.pull_parser PullSpec])) | |
;; lightly adapted from: | |
;; https://github.com/tonsky/datascript/blob/master/src/datascript/pull_api.cljc | |
;; https://github.com/tonsky/datascript/blob/master/src/datascript/pull_parser.cljc |
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
#!/usr/bin/env bb | |
;; convert.clj -- babashka edn/json/yaml to edn/json/yaml converter | |
;; Author: github.com/KGOH/ | |
;; Source: gist.github.com/KGOH/50c0f66022fea2ac173518a143238058 | |
;; Version: 2020.3 | |
; Usage example: | |
; In Emacs: i.imgur.com/TIEDmga.mp4 | |
; $ convert.clj edn <<< '{"foo": "bar"}' | |
; {:foo "bar"} |
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 kc.datomic | |
"Datomic utility functions | |
Usage Notes: | |
Some functions in this namespace take sequences of facts and return them modified in some way. Some up-front modifications are useful for those functions, like replacing all map-form facts with vector-form facts. In order to avoid doing these modifications repeatedly to same the same set of facts (which would be harmless but wasteful), two versions of these functions exist: a \"safe\" version that does those up-front modifications, and an \"unsafe\" version that expects those modifications to already have been performed. The unsafe versions are named like the safe ones, but with a single quote appended. | |
TODO: | |
- consider implementing all fns that branch based on operation as multimethods | |
These fns mostly support :db/add, :db/retract :db.fn/retractEntity, :db.fn/cas, |
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 user) | |
; Hey, I've been playing a bit with graphing out the structure of a module for Lightpad. | |
; It worked well, I've found the target function that I'll need change to add a new feature. | |
; Tweet with a screenshot https://twitter.com/spacegangster/status/1324760381735272450 | |
; lein coordinate | |
; [com.gfredericks/clj-usage-graph "0.3.0"] | |
; https://github.com/gfredericks/clj-usage-graph | |
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
(defn recursive-rule | |
"A recursive rule for establishing prototype inheritance/isa relationship. | |
Can specify a maximum depth to travel, or none if there are no restrictinos. | |
rule The name of the rule | |
e The entity | |
a The attribute | |
v The value | |
Should be creating the rule like: (recursive-rule 'isa '?e '?a '?v) | |
Then within a query, can refer to it like this: | |
(isa ?e :thing/isa ?v) " |
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
;; RGA | |
;; https://speakerdeck.com/ept/data-structures-as-queries-expressing-crdts-using-datalog?slide=22 | |
(def schema | |
{:id/node {:db/valueType :Number} | |
:id/ctr {:db/valueType :Number} | |
:insert/id {:db/valueType :Eid} | |
:insert/parent {:db/valueType :Eid} | |
:assign/id {:db/valueType :Eid} | |
:assign/elem {:db/valueType :Eid} |
OlderNewer