Skip to content

Instantly share code, notes, and snippets.

View README.md
@mping
mping / example.sh
Created Feb 23, 2021
jvisualvm with logging
View example.sh
bin/jvisualvm --jdkhome /home/mping/.asdf/installs/java/adopt-openjdk-11.0.1+13 -J-Djava.util.logging.config.file=vvm.properties --openjmx localhost:10101
❯ cat /home/mping/Devel/visualvm_204/vvm.properties
handlers=java.util.logging.ConsoleHandler
.level=INFO
java.util.logging.ConsoleHandler.level=FINEST
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
javax.management.level=FINEST
javax.management.remote.level=FINEST
View either.clj
(require '[clojure.spec.alpha :as s])
(s/def ::test (s/and (s/keys :req-un [(or ::key1 ::key2)])
(fn [{:keys [key1 key2]}]
(not (and key1 key2)))))
;; s/or validates some of the keys
;; the (fn..) ensures that both keys CANNOT be present
View lazy_channel.clj
(require '[clojure.core.async :as a])
(defn pull-seq
"Returns a (blocking!) lazy sequence read from a channel."
[c]
(lazy-seq
(a/>!! c :ready)
(when-let [v (a/<!! c)]
(cons v (pull-seq c)))))
@mping
mping / sliding_window.clj
Created Nov 19, 2020
Sliding window example
View sliding_window.clj
(defn- new-window [counter prev ts]
(assoc counter :curr 0 :prev prev :last-ts ts))
(defn- increase-count [counter val ts]
(assoc counter :curr val :last-ts ts))
(defn- inc! [counter]
(swap! counter
(fn [{:keys [prev curr last-ts window-ms window-allow] :as atm}]
@mping
mping / defmulti.clj
Last active May 25, 2020
Clojure hierarchy with multimethods
View defmulti.clj
(defn dispatch-fn [o]
(println (vals (select-keys o [:type :entity])))
[(or (get o :type) ::any)
(or (get o :entity) ::any)])
(def hiera (atom (-> (make-hierarchy)
(derive :string ::any)
(derive :object ::any))))
View doc.org

Kubernetes the Exoscale way

Prerequisites

  • exo CLI
  • cs
  • jq

Creating the infrastructure

Private network

@mping
mping / columns.md
Last active Feb 14, 2020
Markdown columns side by side
View columns.md

Document Title

The usual Markdown Cheatsheet does not cover some of the more advanced Markdown tricks, but here is one. You can include verbatim HTML in your Markdown document. This is particularly useful for tables. Check this out:

Version 1Version 2
@mping
mping / test.js
Last active May 13, 2019
geojson > svg through d3
View test.js
const json = {
"routes": [{
"legs": [{
"summary": "Avenida Infante Dom Henrique, Autoestrada do Norte",
"weight": 11481.1,
"duration": 10976.2,
"steps": [{
"intersections": [{
"out": 0,
"entry": [true],
@mping
mping / capslock_ijkl_fn.json
Last active Jan 18, 2019
karabiner://karabiner/assets/complex_modifications/import?url=file:/Users/mping/Devel/workspace/capslock_ijkl_fn.json
View capslock_ijkl_fn.json
{
"title": "Caps Lock (Fn) + IJKL",
"rules": [
{ "description": "Caps Lock to fn",
"manipulators": [{"type": "basic", "from": {"key_code": "caps_lock", "modifiers": {"optional": ["any"]}}, "to": [{"key_code": "fn"}]}] },
{ "description": "Fn + I/J/K/L to Arrow Keys",
"manipulators": [{"type": "basic", "from": {"key_code": "i", "modifiers": {"mandatory": ["fn"], "optional": ["any"]}}, "to": [{"key_code": "up_arrow"}] },
{"type": "basic", "from": {"key_code": "j", "modifiers": {"mandatory": ["fn"], "optional": ["any"]}}, "to": [{"key_code": "left_arrow"}]},
{"type": "basic", "from": {"key_code": "k", "modifiers": {"mandatory": ["fn"], "optional": ["any"]}}, "to": [{"key_code": "down_arrow"}]},
{"type": "basic", "from": {"key_code": "l", "modifiers": {"mandatory": ["fn"], "optional": ["any"]}}, "to": [{"key_code": "right_arrow"}]}] },