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 | |
// depends on vakata/jwt (any other jwt should work too) | |
// composer require vakata/jwt | |
/* | |
// auth.json contains ServiceAccountCredentials | |
// the only required fields are client_email and private_key | |
$uploader = GoogleCloudStorage::fromFile('auth.json', '<bucket-name>'); | |
var_dump($uploader->listBucket()); |
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 for a stack of callables | |
class Dispatcher | |
{ | |
protected array $stack; | |
public function __construct(array &$stack) | |
{ | |
$this->stack = $stack; | |
} | |
public function __invoke(RequestInterface $req) |
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 | |
namsepace vakata\zip; | |
class Zip | |
{ | |
protected $compression = false; | |
protected $data = []; | |
protected $ctrl = []; | |
protected $offset = 0; |
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
/* | |
1) Open your calendar on trainerroad | |
2) Press F12 to open developer tools, select console and paste the script below | |
3) OPTIONAL - modify the two dates (beg & end) to suit your needs | |
4) Copy the result of the execution (something like TRData = ...) | |
*/ | |
(function () { | |
var beg = '2021-01-01'; | |
var end = '2022-01-01'; | |
function normalizeDate(dat) { |
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
function strtotime (text, now) { | |
var parsed, match, today, year, date, days, ranges, len, times, regex, i; | |
if (!text) { | |
return false; | |
} | |
// Unecessary spaces | |
text = text.replace(/^\s+|\s+$/g, '') | |
.replace(/\s{2,}/g, ' ') |
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 kzp($emails) { | |
if(!is_array($emails)) { $emails = [ (string)$emails ]; } | |
if(false === ($hashes = @file('http://www.kzp.bg/download.php?mode=fileDownload&p_attached_file_id=4956'))) { | |
throw new Exception('Could not load KZP hashes'); | |
} | |
array_walk($hashes, function (&$hash) { $hash = substr(strtoupper(trim($hash)),0,32); }); | |
return array_filter(array_unique($emails), function ($mail) use ($hashes) { | |
$mail = mb_strtolower(trim($mail),'utf-8'); | |
return filter_var($mail, FILTER_VALIDATE_EMAIL) && !in_array(strtoupper(md5(explode('@', $mail)[1])), $hashes) && !in_array(strtoupper(md5($mail)), $hashes); |
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
$xml = simplexml_load_file('FileZilla.xml'); | |
$csv = fopen('FileZilla.csv','w'); | |
fputcsv($csv, ["Account","Login Name","Password","Web Site","Comments"]); | |
foreach($xml->xpath('//Server') as $server) { | |
fputcsv($csv, [(string)$server->Name, (string)$server->User, (string)$server->Pass, ((int)$server->Protocol ? 'sftp://' : 'ftp://' ) . (string)$server->Host.':'.(string)$server->Port, (string)$server->Comments]); | |
} | |
fclose($csv); |