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 / 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
# Deploy an additional thanos-store-gateway instance in to feed
# thanos-querier with TSDB from a different cluster S3 bucket
# (no direct connectivity between clusters)
# There `clusterfoo` is the "remote" cluster, running under
# a different AWS_ACCOUNT_NUM, using kiam to assume a role
# able to read the S3 bucket.
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:

Steps to setup Telegram(TG) Cornix BOT autotrading, feeding from Hirn Crypto Free signals TG channel against Binance.

These signals instruct the BOT to trade altcoins against BTC, towards getting returns in BTC, typically via high-freq trading (sometimes ~handful trades per min).

  • [1] Add cornix bot to TG: https://t.me/cornix_trading_bot (free trial 2/weeks)
  • [2] Add Hirn Crypto Free (signals) to TG: https://t.me/hirn_Crypto (free)
  • [3] Create Binance API key, only allowing in-account trading (default), save key and secret
  • Setup cornix bot, from Main Menu ->
    • Add Another Client -> New Client -> Link to an existing account -> Binance using API <key>,<secret> from [3]
    • Subscribe to Channel -> should automagically show Hirn ... from [2]