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
Author: Mikko Rantalainen | |
License: CC-0 | |
Here's an idea that should only require two rounds and all published data to anybody can be immediately public to whole group and published in any order and you only need a good enough hash to store passwords safely and a good enough one-way hash that changes a lot when input changes even by one bit. I'm using bcrypt and SHA-512 as an example but feel free to use any other algorithm: | |
1. Everybody creates a new ASCII string that identifies them to the group. For example, email address would be okay. | |
2. Everybody creates their own secret data as ASCII text string (e.g. UUID v4) | |
3. Everybody concatenates the strings from step 1 and step 2 with a colon, which would result in their secret string of format "email:UUID" | |
4. Everybody publishes bcrypt hash for the string generated in step 3. Everyone can freely select the salt and cost factors to match his or her expectations to make sure the private key cannot be decrypted during the secret santa selection process. Random max |
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. | |
# |