Skip to content

Instantly share code, notes, and snippets.

View mping-exo's full-sized avatar

Miguel Ping mping-exo

  • Lisbon, Portugal
View GitHub Profile
@mping-exo
mping-exo / custom-hints-uuid.py
Created September 21, 2023 09:20
Kitty highlighter
from kitty.clipboard import set_clipboard_string, set_primary_selection
import re
def mark(text, args, Mark, extra_cli_args, *a):
# This function is responsible for finding all
# matching text. extra_cli_args are any extra arguments
# passed on the command line when invoking the kitten.
# We mark all individual word for potential selection
@mping-exo
mping-exo / main.go
Created November 30, 2022 14:28
xxhash golang
package main
import (
"fmt"
"io"
"os"
"reflect"
"github.com/cespare/xxhash/v2"
@mping-exo
mping-exo / handshake.md
Last active July 1, 2022 08:46
nbd example

setup

virt-install --name ubuntu18 --vcpus 4 --memory 2048 --disk path=ubuntu18.iso,bus=virtio,cache=writeback --graphics vnc,listen=0.0.0.0  --noautoconsole --os-variant=ubuntu18.10 --import --virt-type kvm

;; virsh 8.0.0
virsh attach-disk ubuntu18 --source foo --source-protocol nbd --source-host-name localhost:6666 --target vde

;; xml
<disk type='network'>
@mping-exo
mping-exo / fix-idea.sh
Created June 8, 2022 13:25
fix idea classpath
#!/bin/bash
xml='<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dev" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/checkouts" />
<excludeFolder url="file://$MODULE_DIR$/target" />
@mping-exo
mping-exo / fix-idea.sh
Created December 2, 2021 10:11
fix-idea.sh
#!/bin/bash
xml='<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/checkouts" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>'
@mping-exo
mping-exo / metrics
Created July 16, 2021 14:47
ot collector metrics
# HELP otelcol_exporter_queue_size Current size of the retry queue (in batches)
# TYPE otelcol_exporter_queue_size gauge
otelcol_exporter_queue_size{exporter="otlp",service_instance_id="0afa6250-8064-4913-9a60-fe23ae50dd52"} 0
# HELP otelcol_exporter_send_failed_spans Number of spans in failed attempts to send to destination.
# TYPE otelcol_exporter_send_failed_spans counter
otelcol_exporter_send_failed_spans{exporter="logging",service_instance_id="0afa6250-8064-4913-9a60-fe23ae50dd52"} 0
otelcol_exporter_send_failed_spans{exporter="otlp",service_instance_id="0afa6250-8064-4913-9a60-fe23ae50dd52"} 675
# HELP otelcol_exporter_sent_spans Number of spans successfully sent to destination.
# TYPE otelcol_exporter_sent_spans counter
otelcol_exporter_sent_spans{exporter="logging",service_instance_id="0afa6250-8064-4913-9a60-fe23ae50dd52"} 1.974518e+06
(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
@mping-exo
mping-exo / interceptors.clj
Created September 15, 2020 08:08
interceptors.clj
(defn fn-1arity [one-arg]
(inc one-arg))
(defn fn-future [res]
(d/future
(Thread/sleep 1000)
res))
(defn fn-2arity [a b]
@mping-exo
mping-exo / manifold.clj
Created June 26, 2020 09:31
ablauf deferred
(d/on-realized (d/chain (d/success-deferred 1)
#(println "ok" %))
(fn ok [v] (println "Realized" v))
(fn fail [e] (println "fail " e)))
;; ok 1
;; realized nil
(d/on-realized (d/chain (d/error-deferred 1)
#(println "ok" %))
(fn ok [v] (println "Realized" v))