Skip to content

Instantly share code, notes, and snippets.

View jjo's full-sized avatar
🏠
Working from home

JuanJo Ciarlante jjo

🏠
Working from home
View GitHub Profile
@jjo
jjo / netfilter-exporter.grafana.com_netfilterclasses.yaml
Last active June 27, 2025 20:10
netfilter-exporter.grafana.com_netfilterclasses.yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.5
name: netfilterclasses.netfilter-exporter.grafana.com
spec:
group: netfilter-exporter.grafana.com
names:
#!/usr/bin/env python
## Ejemplo minimo para resolver caso1: solo dos sucursales,
## se debe generalizar teniendo por ej suc_count=6 via codigo.
## --jjo, 2025-04-25
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
@jjo
jjo / summary.md
Last active November 17, 2024 03:58
https://benjdd.com/loops/ (from https://x.com/BenjDicken/status/1857449788893286484) in C and Go, Go version built natively and as WASM

Summary:

how walltime CPU MEM obs
build-c-native/main 0:01.10 99% 1408k
build-c-wasm/main.wasm 0:07.26 99% 37888k with wasmer
build-c-wasm/main.wasm 0:07.34 99% 15232k with wasmtime
build-go-native/main 0:05.80 100% 1536k
build-go-wasm/main.wasm 0:05.61 99% 55388k with wasmer
build-go-wasm/main.wasm 0:05.69 97% 28768k with wasmtime
@jjo
jjo / Dockerfile
Last active October 21, 2024 22:58
Dockerfile to build a containerized `firefox` (under Debian), plus `run.sh` to run it -- READ THE DANGERS
# Use Debian Bookworm as the base image
FROM debian:bookworm-slim
# Update the package list and install necessary dependencies
RUN apt-get update && apt-get install -y \
firefox-esr \
libcanberra-gtk3-module \
libdbus-glib-1-2 \
libgtk-3-0 \
libx11-xcb1 \
@jjo
jjo / 01-promql-vector-label_replace-abuse.md
Last active November 23, 2023 18:38
PromQL fun abusing `vector()` and `label_replace()` to create ~arbitrary timeseries, note these are used from grafana's /explore (for those ${__to:...} expressions)

Building a sinusoidal, back from now, using vector and label_replace.

round(
    8  # <- number of nodes
    *
    (1-sin(vector((time()-(${__to:date:seconds}))/(3600*10) * pi()))) / 2
)
* on() group_right() (
 label_replace(vector(0.0445000) , "spend", "cpu", "", "") * 8 # &lt;- vCPU per node
@jjo
jjo / dotssh-config-add.cfg
Last active January 29, 2022 22:46
ssh config stanza to use `gcloud beta ssh ...` straight via `ssh` CLI
### Add below stanza to your ~/.ssh/config
## Parsed as vmname.REGION.PROJECT.gcp
Host *.*.*.gcp
ProxyCommand gcloud beta compute ssh --tunnel-through-iap $(echo %h|awk -v FS=. '{ printf ("--project=%%s --zone=%%s %%s", $3, $2, $1) }') --command="nc -q0 localhost 22"
$ cat > foo.jsonnet
local applyModifications(obj, f) =
obj + {
[x] : f(obj[x]) for x in std.objectFieldsAll(obj)
}
;
applyModifications({
visible: "foo",
hidden:: "bar",
$ /tmp cat > foo.jsonnet
local applyModifications(obj, f) =
obj + {
[x] : f(obj[x]) for x in std.objectFieldsAll(obj)
}
;
applyModifications({
visible: "foo",
hidden:: "bar",
#!/bin/zsh
which ip >& /dev/null || { echo "Needs 'brew install iproute2mac'" ; exit 1;}
[[ $(id -u) == 0 ]] || { echo "Needs root (sudo)" ; exit 1;}
fix() {
(set -x
ip r $DEL 0.0.0.0/1 via 10.99.0.1 dev utun2
ip r $DEL 128.0.0.0/1 via 10.99.0.1 dev utun2
## Specific routes:
# whois $(dig +short github.com)|egrep CIDR
{
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "jjo-nginx",
"creationTimestamp": null,
"labels": {
"app": "jjo-nginx"
}
},