Skip to content

Instantly share code, notes, and snippets.

Avatar

Miguel Ping mping-exo

  • Lisbon, Portugal
View GitHub Profile
View handshake.md

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
@mping-exo
mping-exo / fix-idea.sh
Created Jun 8, 2022
fix idea classpath
View fix-idea.sh
#!/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" />
View NettyByteString.java
package com.google.protobuf;
import io.netty.buffer.ByteBuf;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.InvalidMarkException;
import java.nio.charset.Charset;
import java.util.Collections;
View 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 Jul 16, 2021
ot collector metrics
View 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
View 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]
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 manifold.clj
(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))