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 | |
# | |
# bench.sh | |
# https://gist.github.com/tdebatty/0358da0a2068eca1bf4583a06aa0acf2 | |
# | |
# https://cylab.be/blog/351/performance-of-virtual-storage-part-2-qemu | |
# | |
# a wrapper for sysbench | |
# quick run: |
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
.env (and .env.example): | |
DB_CONNECTION=sqlite | |
config/database.php: | |
connections => sqlite | |
'database' => __DIR__ . '/../storage/app/db.sqlite', | |
touch storage/app/db.sqlite |
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 | |
$context = array(); | |
$proxy = getenv("http_proxy"); | |
if ($proxy !== null) { | |
$context['http'] = array( | |
'proxy' => str_replace("http", "tcp", $proxy), | |
'request_fulluri' => true | |
); | |
} |
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
import java.util.ArrayList; | |
/** | |
* Helper class to perform the sum of a large number of values. | |
* A double value in java only has 15 significant digits. Hence, when performing | |
* the sum of a large number of double values, the precision of the result | |
* may be highly altered. For example, if performing the sum of 1E9 values, | |
* the result only has 6 significant digits. This helper class performs the | |
* addition using groups of 1E5 values. The result has 10 significant digits, | |
* for sums of up to 1E10 values. |
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
// !! this gist was created in 2015, it doesn't work on most modern distributions !! | |
// e.g: get_ip("eth0"); | |
function get_ip($interface) { | |
$interface = escapeshellarg($interface); | |
$pattern = "/inet addr:(\d+\.\d+\.\d+\.\d+)/"; | |
$text = shell_exec("ifconfig $interface"); | |
preg_match($pattern, $text, $matches); | |
return $matches[1]; | |
} |
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
#! /usr/bin/php | |
<?php | |
// Allows you to filter which USB devices may be connected to your system | |
// To find the ID of devices: | |
// sudo pkill udevd | |
// sudo udevd --debug | |
// Setup: | |
// Save this file to /opt/udev-filter-usb |
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 | |
/** | |
* A PHP implementation of spamsum algorithm | |
* https://junkcode.samba.org/ftp/unpacked/junkcode/spamsum/ | |
* | |
* The spamsum algorithm is also used by ssdeep | |
* http://ssdeep.sourceforge.net/ | |
* | |
* Usage: | |
* $ss = new SpamSum(); |
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 | |
/** | |
* A simple function that uses mtime to delete files older than a given age (in seconds) | |
* Very handy to rotate backup or log files, for example... | |
* | |
* $dir String whhere the files are | |
* $max_age Int in seconds | |
* return String[] the list of deleted files | |
*/ |
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 | |
/* A quick and dirty PHP implemenation of NNDescent algorithm, as proposed in the paper | |
* Efficient k-nearest neighbor graph construction for generic similarity measures | |
* http://dl.acm.org/citation.cfm?id=1963487 | |
* | |
*/ | |
/** | |
* The algorithm can be used with any kind of item, as long as some | |
* similarity metric is defined |