This file contains hidden or 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
# values from https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Welcome%20to%20High%20Performance%20Computing%20%28HPC%29%20Central/page/Linux%20System%20Tuning%20Recommendations | |
# install (root): curl -s https://gist.githubusercontent.com/polonskiy/00a71bab32360ffcb79f/raw/10-custom.conf > /etc/sysctl.d/10-custom.conf | |
# apply (root): sysctl -p /etc/sysctl.d/10-custom.conf | |
net.ipv4.neigh.default.gc_thresh1 = 30000 | |
net.ipv4.neigh.default.gc_thresh2 = 32000 | |
net.ipv4.neigh.default.gc_thresh3 = 32768 | |
net.ipv6.neigh.default.gc_thresh1 = 30000 | |
net.ipv6.neigh.default.gc_thresh2 = 32000 |
This file contains hidden or 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 | |
$data = file_get_contents('php://stdin'); | |
$password = 'ps8T0G/39oHgRehuV0TjUv2lyeA='; | |
$c = rkxor($data, $password); | |
$x = rkxor($c, $password); | |
var_dump($c,$x); | |
function rkxor($data, $password) { |
This file contains hidden or 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 | |
class Runner { | |
public function __construct() { | |
pcntl_signal(SIGCHLD, SIG_IGN); | |
} | |
public function go() { | |
if (pcntl_fork()) return; |
This file contains hidden or 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
#!/usr/bin/php | |
<?php | |
$data = file_get_contents('php://stdin'); | |
preg_match('#^To:(.*)#i', $data, $matches); | |
$filename = tempnam('/tmp', trim($matches[1]) . '_'); | |
file_put_contents($filename, $data); |
This file contains hidden or 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 | |
$server = stream_socket_server('tcp://127.0.0.1:8000'); | |
while (true) { | |
$client = stream_socket_accept($server, -1); | |
if (pcntl_fork() === 0) { | |
stream_copy_to_stream($client, $client); | |
die; | |
} | |
fclose($client); |
This file contains hidden or 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
#!/usr/bin/php | |
<?php | |
$argv += [1 => 'localhost', 2 => 11211]; | |
$memcached = new Memcached; | |
$memcached->addServer($argv[1], $argv[2]); | |
$result = []; | |
foreach($memcached->getAllKeys() as $k) $result[$k] = $memcached->get($k); | |
var_export($result); | |
echo ";\n"; |
This file contains hidden or 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 | |
class FSStorage { | |
protected $dir; | |
public function __construct($dir) { | |
$this->dir = $dir; | |
} |
This file contains hidden or 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 similar_text_shingles($texts, $shingle_len = 10, $algo = 'md5') { | |
$c = count($texts); | |
$total = 0; | |
for ($i = 0; $i < $c; $i++) { | |
preg_match_all('#\w{4,}#u', mb_strtolower($texts[$i], 'utf-8'), $matches); | |
$words = $matches[0]; | |
$cc = count($words) - $shingle_len; | |
for ($j = 0; $j < $cc; $j++) { |
This file contains hidden or 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 byte2($bytes) { | |
$size = array('B','KB','MB','GB','TB'); | |
$factor = floor(log($bytes, 1024)); | |
$format = $factor > 2 ? '%.1F %s' : '%u %s'; | |
return sprintf($format, $bytes / pow(1024, $factor), $size[$factor]); | |
} |
This file contains hidden or 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 | |
sleep ${1:-25}m | |
notify-send -i clock 'Time is up' |