View php-elasticsearch-escape.php
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 |
View PHP lambda performance results
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", |
View speedtest-cloudflare
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 <mikko.rantalainen@iki.fi> | |
# 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)" |
View traffic-shaping
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 <mikko.rantalainen@gmail.com> | |
# 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. | |
# |