Skip to content

Instantly share code, notes, and snippets.

View mikkorantalainen's full-sized avatar

Mikko Rantalainen mikkorantalainen

  • Peda.net, University of Jyväskylä
  • Finland
View GitHub Profile
#!/bin/bash
# Traffic shaping script (AQM, fq_codel+tbf)
# Copyright 2018 Mikko Rantalainen <[email protected]>
# License: MIT (X11)
# Usage:
# 21/0.8 Mbps connection (ADSL2): DOWNLINK_RATE=21.7Mbit UPLINK_RATE=0.8Mbit TBF_LATENCY=500ms bin/traffic-shaping start
# 100/100 Mbps connection: ./traffic-shaping
# 1/1 GBps connection: DOWNLINK_RATE=1Gbit UPLINK_RATE=1Gbit TBF_LATENCY=10ms bin/traffic-shaping start
# Note that using low TBF_LATENCY will require powerful CPU.
#
#!/bin/bash
# Speedtest using speed.cloudflare.com servers
# Copyright 2020 Mikko Rantalainen <[email protected]>
# License: 2-clause BSD (https://opensource.org/licenses/BSD-2-Clause)
set -e
ID="$RANDOM$RANDOM$RANDOM"
BYTES="${BYTES:=1000000}"
SERVER="https://speed.cloudflare.com"
TEMPFILE="$(tempfile -p speed -s test)"
Live version: https://3v4l.org/6AABv
Test script:
<?php
$a = array(
0 => "foo",
1 => "bar",
"animal" => "string",
3.13 => "pi",
<?php
function escapeElasticReservedChars($string) {
$regex = "/[\\+\\-\\=\\&\\|\\!\\(\\)\\{\\}\\[\\]\\^\\\"\\~\\*\\<\\>\\?\\:\\\\\\/]/";
return preg_replace($regex, addslashes('\\$0'), $string);
}
/**
* @param string $s untrusted user input
@mikkorantalainen
mikkorantalainen / bitwarden-backup
Created March 10, 2023 08:34
Bash script to create full Bitwarden vault backup on Ubuntu host, backup file will be saved as AES-256 encrypted ZIP file
#!/bin/bash
#
# Backup Bitwarden vault to AES-256 encrypted ZIP file
# Copyright 2023 Mikko Rantalainen <[email protected]>
# License: MIT
#
set -o errexit
DATE="$(date +%Y-%m-%d)"
ZIPFILENAME="$(pwd)/bitwarden-backup-$DATE.zip"