Skip to content

Instantly share code, notes, and snippets.

View partition-while.clj
(defn partition-while
"Given a coll, partition the coll whenever `(f a b)` returns `false`.
Example: `(partition-when #(<= 0 (Math/abs (- %1 %2)) 1) [1 2 3 5 6 8 10 10])
returns `[[1 2 3] [5 6] [8] [10 10]]`
([f coll] (partition-while f coll [] []))
([f [_ & t :as c] result intermediate]
(let [[a b & _] c]
(nil? a) result
mping / CljKeyStore.clj
Created Dec 3, 2018
Kafka props in clojure
View CljKeyStore.clj
(ns com.heroku.sdk.CljKeyStore
"Dynamically generated class to allow creating custom key stores by directly passing the certs and keys
instead of relying on env vars"
:name com.heroku.sdk.CljKeyStore
:extends com.heroku.sdk.EnvKeyStore
:methods [#^{:static true} [fromTrustWithRandomPassword [String] com.heroku.sdk.EnvKeyStore]
#^{:static true} [fromKeyAndCertWithRandomPassword [String String] com.heroku.sdk.EnvKeyStore]]
:constructors {[String String] [String String],
[String String String] [String String String]}))
mping /
Created Sep 22, 2018 — forked from Deraen/
Compojure-api and Buddy
  • (:identity req) is auth backend independent way to access user data
  • login and logout implementation depends on auth backend
  • :current-user doesn't imply that authentication is required, route should also have :auth-rules if authentication is required
mping /
Last active Jun 9, 2018 — forked from abravalheri/
RFC: Git Commit Message Guidelines

Commit Message Guidelines


  • allow generating by script
  • allow ignoring commits by git bisect (not important commits like formatting)
  • provide better information when browsing the history


mping / profiles.clj
Last active Apr 19, 2018
View profiles.clj
{:user {:plugins [[cider/cider-nrepl "0.16.0"]
[lein-midje "3.1.3"]
[lein-cloverage "1.0.9"]
[com.jakemccrary/lein-test-refresh "0.21.1"]
[lein-ancient "0.5.5"]
[jonase/eastwood "0.2.5"]
[lein-kibit "0.0.8"]
[lein-pprint "1.1.2"]]}}
View .zshrc
alias pserv='python -m SimpleHTTPServer $*'
alias wget='wget --trust-server-names --no-check-certificate'
alias ls='LC_COLLATE=C ls -lFha -G' #--group-directories-first --color '
alias grep='grep --color=always'
alias less='less -R'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
mping /
Last active Mar 27, 2018
CompletableFuture gotcha
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class FutureWUT {
static void sleep(long millis) {
try {
mping / core.clj
Created Jan 29, 2018
quasar producer
View core.clj
(ns clj-quasar.core
[core :refer :all]
[actors :refer :all]]))
(defsfn adder []
(receive [from v]
(+ v 1))))

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea