Skip to content

Instantly share code, notes, and snippets.

View JensRantil's full-sized avatar

Jens Rantil JensRantil

View GitHub Profile
@JensRantil
JensRantil / README.md
Last active April 5, 2024 11:47
This is proof of concept how length of the labels in Graphviz impacts the layout.

This is proof of concept how length of the labels in Graphviz impacts the layout.

@JensRantil
JensRantil / generate-interest-posts.py
Created January 7, 2023 11:34
Script that generates monthly plain text accounting (https://plaintextaccounting.org) interest records for fixed-rate savings accounts. Amounts are faked.
#!/bin/python
from collections import namedtuple
from datetime import date, timedelta
import itertools
import logging
logging.basicConfig(level=logging.DEBUG)
@JensRantil
JensRantil / vuejs.sh
Created March 8, 2022 14:03
Stats on most common author in VueJS project
$ git log -1
commit 6aa11872c88481dfa2da151536317176c48f226c (HEAD -> dev, origin/dev, origin/HEAD)
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue Feb 22 19:38:12 2022 +0100
build(deps): bump ajv from 6.6.2 to 6.12.6 (#12468)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
$ find . -type f -exec cat {} + | wc -l
307257
$ sstabledump ./mykeyspace/mytable/mc-12109-big-Data.db | awk '/key/ {print counter, key;counter=0;key=$0;} /^ / {counter++;}' | sort -n | tail -n 40
@JensRantil
JensRantil / cassandra_netstats_progress.sh
Last active January 13, 2023 02:50
Hacky one-liner for estimating progress when adding a new Cassandra node. Run on the join that’s joining and be sure to set NODES to number of nodes in the cluster that are streaming to the new node.
#!/bin/bash
while [ 1 ];do date -Iseconds | tr -d '\n';sudo nodetool netstats | grep Receiving | grep -Eo '[0-9]* bytes' | sed 's/ bytes//' | awk 'BEGIN {NODES=6;} NR%2==1 {TOTAL+=$0;} NR%2==0 {PROGRESS+=$0;} END {NODESRUNNING=NR/2;NODESDONE=NODES-NODESRUNNING;print " progress:", 100*(NODESDONE/NODES+(NODESRUNNING/NODES)*(PROGRESS/TOTAL)) "%", "running:", NODESRUNNING, "done:", NODESDONE;}';sleep 30;done
@JensRantil
JensRantil / simulate_cassandra_load.py
Created June 23, 2021 22:31
Small script to simulate rack-aware Cassandra reads/writes.
import random
original = [
["RAC1"],
["az-A-0", "az-A-1"],
["az-B-0", "az-B-1"],
["az-C-0", "az-C-1"],
]
remove_rac1 = [
["az-A-0", "az-A-1"],
module github.com/JensRantil/kafka-pinger
go 1.15
require (
github.com/frankban/quicktest v1.11.3 // indirect
github.com/golang/protobuf v1.5.1 // indirect
github.com/golang/snappy v0.0.2 // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/kr/text v0.2.0 // indirect
import random
# Number of VMs that will be restarted.
N=16
# Bucket the nodes randomly by hashing their hostnames and putting them in hourly buckets.
BUCKETS = 7*24
# Number of simulations we will make.
SIMULATIONS=100000
collisions = 0
@JensRantil
JensRantil / example-output.txt
Last active October 23, 2020 14:01
Kafka script to generate Bash commands that will recreate Kafka topics. Possibly useful for backups of topics.
./bin/kafka-topics.sh --if-not-exists --zookeeper $(grep -E zookeeper.connect= ./config/server.properties | cut -d= -f2) --create --partitions 12 --replication-factor 3 --topic my-topic-1 --config retention.ms=3600000 --config min.insync.replicas=2
./bin/kafka-topics.sh --if-not-exists --zookeeper $(grep -E zookeeper.connect= ./config/server.properties | cut -d= -f2) --create --partitions 1 --replication-factor 3 --topic my-topic-2 --config min.insync.replicas=2
module github.com/JensRantil/yo
go 1.13
require github.com/nats-io/nats-streaming-server v0.16.2