Skip to content

Instantly share code, notes, and snippets.

mping / object_define_property.js
Created Jun 24, 2015
Object.defineProperty and debugger
View object_define_property.js
// Nice trick when you don't know where a change comes from
// rewrites a property, and sets a debugger when the property changes
console = console || {}; // just in case = function(oObj, sProp) {
var sPrivateProp = "$_"+sProp+"_$"; // to minimize the name clash risk
oObj[sPrivateProp] = oObj[sProp];
// overwrite with accessor
mping /
Created Jul 4, 2022 — forked from rizalgowandy/
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2

To use media keys on the Ducky One 2, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.


Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

mping /
Created Apr 12, 2011
Enables Flying Saucer (xhtmlrendered java lib) to process <img> tags with b64 data
import org.w3c.dom.Element;
import org.xhtmlrenderer.extend.FSImage;
import org.xhtmlrenderer.extend.ReplacedElement;
import org.xhtmlrenderer.extend.ReplacedElementFactory;
import org.xhtmlrenderer.extend.UserAgentCallback;
import org.xhtmlrenderer.layout.LayoutContext;
import org.xhtmlrenderer.pdf.ITextFSImage;
import org.xhtmlrenderer.pdf.ITextImageElement;
mping /
Created Feb 23, 2021
jvisualvm with logging
bin/jvisualvm --jdkhome /home/mping/.asdf/installs/java/adopt-openjdk-11.0.1+13 --openjmx localhost:10101
❯ cat /home/mping/Devel/visualvm_204/
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."
(a/>!! c :ready)
(when-let [v (a/<!! c)]
(cons v (pull-seq c)))))
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 / 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))))

Kubernetes the Exoscale way


  • exo CLI
  • cs
  • jq

Creating the infrastructure

Private network