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 / summary.md
Last active November 16, 2024 14:09
https://benjdd.com/loops/ (from https://x.com/BenjDicken/status/1857449788893286484) in C and Go, Go version built natively and as WASM

Summary:

Lang Target Wall time CPU util MaxRSS obs
C native build 0:01.0s 99% 1.37MiB baseline
Go native build 0:05.48 99% 1.75MiB
Go wasm 0:05.50 99% 54.00MiB ran using wasmer
Go wasm 0:05.64 99% 24.61MiB ran using 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"
}
},
@jjo
jjo / mtr-jjo.txt
Last active August 18, 2020 15:56
$ mtr www.nhs.uk
My traceroute [v0.93]
jjo-x270 (192.168.0.106) 2020-08-18T12:55:27-0300
Keys: Help Display mode Restart statistics Order of fields quit
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. ip-192-168-0-1.ec2.internal 0.0% 10 3.2 13.5 1.4 77.5 25.1
2. static.214.65.itcsa.net 77.8% 10 5.0 4.1 3.3 5.0 1.2
3. (waiting for reply)
4. ae0-90G.ar7.LAX1.gblx.net 10.0% 10 285.3 295.2 283.2 324.0 14.9
@jjo
jjo / Dockerfile
Last active May 13, 2020 15:59
Generic python dockerfile for multistage builds
FROM python:3.8-slim as compile-image
RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc && apt-get clean
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . /app
FROM python:3.8-slim as runtime-image