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 | |
$cards = [ | |
'MasterCard0' => '5555555555554444', | |
'MasterCard1' => '5105105105105100', | |
'Visa0' => '4111111111111111', | |
'Visa1' => '4012888888881881', | |
'Visa2' => '4929000005559', | |
'Visa3' => '4929000000014', | |
'Visa4' => '4929000000022', | |
'Visa5' => '4222222222222', |
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 | |
$filename = 'report_period_' . date('Y-m-d', $time) . '.csv'; | |
$file = sys_get_temp_dir() . '/' . $filename; | |
$fp = fopen($file, 'w'); | |
foreach ($csvData as $r) { | |
fputcsv($fp, $r); | |
} | |
fclose($fp); | |
$size_in_bytes = filesize($file); |
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 | |
// script to parse mac address db at | |
// https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf | |
$data = file('vendors.txt'); | |
foreach ($data as $line) { | |
if (preg_match("/^#.*/", $line)) { | |
continue; | |
} elseif (preg_match("/([A-F0-9]+:[A-F0-9]+:[A-F0-9]+)\s+[^#]+#\s+(.+)/i", $line, $matches)) { |
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 | |
/** | |
* Find unused functions in a legacy project that are safe to remove | |
* | |
* @author: Vijay Mahrra <[email protected]> | |
*/ | |
$folder = 'legacy'; | |
$cmd = "grep -aRi 'function ' $folder/*"; | |
exec($cmd, $results); | |
$removeable = []; |
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 running() { | |
// check if already running, quit if so | |
exec("ps auxww | grep running.php | grep -v grep", $ps); | |
if (count($ps) > 1) { | |
echo "Already running!\n"; | |
return; | |
} | |
sleep(60); | |
} |
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/local/bin/bash | |
DB=$2 | |
HOST=$1 | |
TABLE=$5 | |
USER=$3 | |
PASS=$4 | |
MYSQLDUMP=$(which mysqldump) | |
MYSQLDUMP_OPTS=" --no-create-db --add-locks --add-drop-table --extended-insert --verbose" |
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/sh | |
MYSQLDUMP=`which mysqldump` | |
# mysql settings | |
DB="mysql" | |
HOST="127.0.0.1" | |
USER="root" | |
PASS="root" |
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/sh | |
MYSQLDUMP=`which mysqldump` | |
DB="mysql" | |
HOST="127.0.0.1" | |
USER="root" | |
PASS="root" | |
# backup file settings |
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 | |
/** | |
* Get memory usage in megabytes. | |
* | |
* @return string Memory usage in the format "used/peak" where both values are in MB. | |
*/ | |
function get_memory_used(): string { | |
$memoryUsage = memory_get_usage() / 1024 / 1024; | |
$peakMemoryUsage = memory_get_peak_usage() / 1024 / 1024; |
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/sh | |
# path settings | |
MYSQL=`which mysql` | |
# mysql settings | |
DB="MYDB" | |
HOST="127.0.0.1" | |
USER="root" | |
PASS="root" |