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 | |
namespace App\Console\Commands; | |
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\Artisan; | |
use Illuminate\Support\Facades\Log; | |
use RuntimeException; | |
use Throwable; |
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/env bash | |
SUDO='' | |
if [ "$(id -u)" != "0" ]; then | |
SUDO='sudo' | |
echo "This script requires superuser access." | |
echo "You will be prompted for your password by sudo." | |
# clear any previous sudo permission | |
sudo -k | |
fi |
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 | |
collect([]) | |
->tap(static function (\Illuminate\Support\Collection $collection) { | |
$collection->macro('divide', function (int $chunks = 2) { | |
$size = ceil($this->count() / $chunks); | |
return $this->chunk($size); | |
}); | |
}) |
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 isPalindrome($str) | |
{ | |
$A = ord('A'); | |
$Z = ord('Z'); | |
$a = ord('a'); | |
$z = ord('z'); | |
$Aa = $a - $A; | |
$l = 0; |
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 | |
namespace { | |
use Illuminate\Support\HigherOrderTapProxy; | |
if (!function_exists('tap')) { | |
/** | |
* Call the given Closure with the given value then return the value. | |
* |
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 | |
/** | |
* Class Certbot | |
*/ | |
class Certbot | |
{ | |
/** | |
* @var self | |
*/ |
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 declare(strict_types=1); | |
/** | |
* @param int $base | |
* | |
* @return array[] | |
* | |
* @throws \InvalidArgumentException | |
*/ | |
function generateTruthTable(int $base): array |
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 declare(strict_types=1); | |
namespace Core; | |
class Cache | |
{ | |
private $object = null; | |
private $cache = null; |
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 declare(strict_types=1); | |
function phone_semaphore($phone, callable $callback) | |
{ | |
$sem = sem_get($phone, 1); | |
if (sem_acquire($sem)) { | |
$result = $callback(); | |
sem_release($sem); |
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 | |
$ips = [ | |
'127.0.0.1', | |
]; | |
$ports = [ | |
20 => 'FTP data', | |
21 => 'FTP control port', | |
22 => 'SSH', |