Skip to content

Instantly share code, notes, and snippets.

Avatar

Jens Rantil JensRantil

View GitHub Profile
View gist:03e16420054291d666274d8a2b4730b4
$ 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 Jun 24, 2021
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.
View cassandra_netstats_progress.sh
#!/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 Jun 23, 2021
Small script to simulate rack-aware Cassandra reads/writes.
View simulate_cassandra_load.py
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"],
View go.mod
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
View hostname-hash-bucketing-restart.py
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 Oct 23, 2020
Kafka script to generate Bash commands that will recreate Kafka topics. Possibly useful for backups of topics.
View example-output.txt
./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
View go.mod
module github.com/JensRantil/yo
go 1.13
require github.com/nats-io/nats-streaming-server v0.16.2
@JensRantil
JensRantil / go.mod
Last active May 8, 2019
TopK implementation with filtering from dictionary.
View go.mod
module github.com/JensRantil/topk-challenge
require (
github.com/funkygao/golib v0.0.0-20180314131852-90d4905c1961 // indirect
github.com/google/pprof v0.0.0-20190502144155-8358a9778bd1 // indirect
github.com/hashicorp/go-multierror v1.0.0
github.com/pkg/errors v0.8.1
golang.org/x/arch v0.0.0-20190312162104-788fe5ffcd8c // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58
)
@JensRantil
JensRantil / go.mod
Last active May 3, 2019
Demonstrating potential memory leak.
View go.mod
module github.com/tink-ab/tink-backend/src/nats-streaming-pinger
require (
github.com/armon/go-metrics v0.0.0-20190423201044-2801d9688273 // indirect
github.com/go-sql-driver/mysql v1.4.1 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/hashicorp/go-msgpack v0.5.4 // indirect
github.com/hashicorp/raft v1.0.1 // indirect
github.com/lib/pq v1.1.0 // indirect
github.com/nats-io/gnatsd v1.4.1 // indirect
@JensRantil
JensRantil / go.mod
Last active Apr 25, 2019
A tiny application that connects to NATS and measure latencies to NATS.
View go.mod
module github.com/tink-ab/tink-backend/src/nats-checker
require (
github.com/nats-io/gnatsd v1.4.1 // indirect
github.com/nats-io/go-nats v1.7.2
github.com/nats-io/nkeys v0.0.2 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/oklog/ulid v1.3.1
github.com/prometheus/client_golang v0.9.2
golang.org/x/sys v0.0.0-20190425045458-9f0b1ff7b46a // indirect