Skip to content

Instantly share code, notes, and snippets.

View JensRantil's full-sized avatar

Jens Rantil JensRantil

View GitHub Profile
@JensRantil
JensRantil / retryer.sh
Created September 3, 2015 13:37
A wrapping retrying script.
local runscript=1
while [ $runscript -eq 1 ]; do
./your-script
local exitcode=$?
if [ $status -eq 0 ]; then
runscript=1
else
runscript=0
fi
done
@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 / backup-keyspace.sh
Created November 27, 2014 10:20
Basic Cassandra -> S3 backup script
#!/bin/bash
KEYSPACE=$1
DATE=`date +"%Y-%m-%d--%H-%M-%S"`
FOLDER_NAME=${DATE}-daily
S3_BUCKET=s3://YOUR-S3-BUCKET
S3_BUCKET_PATH=cassandra/full/`date +"%Y/%m/%d/%H/%M"`/`cat /etc/hostname`
SNAPSHOTID=`uuidgen --time`
PGP_KEY_RECIPIENT=YOUR-PGP-KEY-RECIPIENT
@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 / 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 / make_iap_request.py
Last active June 4, 2022 01:46
Make IAP requests from credentials JSON file.
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@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
@JensRantil
JensRantil / execute.sh
Last active November 10, 2021 11:30
Simple test to test SIGINT signal handling of Go.
#!/bin/bash
# Executed on MacOSX
go build signal.go
./signal &
kill -INT $!
# Prints the "interrupt" and quits after 5 seconds, which is to be expected.
$ sstabledump ./mykeyspace/mytable/mc-12109-big-Data.db | awk '/key/ {print counter, key;counter=0;key=$0;} /^ / {counter++;}' | sort -n | tail -n 40
package my.project.ssl;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.List;
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;
import com.google.common.collect.ImmutableList;