This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function escapeElasticReservedChars($string) { | |
$regex = "/[\\+\\-\\=\\&\\|\\!\\(\\)\\{\\}\\[\\]\\^\\\"\\~\\*\\<\\>\\?\\:\\\\\\/]/"; | |
return preg_replace($regex, addslashes('\\$0'), $string); | |
} | |
/** | |
* @param string $s untrusted user input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Live version: https://3v4l.org/6AABv | |
Test script: | |
<?php | |
$a = array( | |
0 => "foo", | |
1 => "bar", | |
"animal" => "string", | |
3.13 => "pi", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. | |
# |