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); | |
// https://stackoverflow.com/a/1653826 | |
// updated for PHP 8 | |
function bcceil(string $number): string | |
{ | |
if (str_contains($number, '.')) { | |
if (preg_match("~\.[0]+$~", $number)) { |
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); | |
#[Attribute(Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] | |
final class Option | |
{ | |
public function __construct( | |
public string|null $short = null, | |
public string|null $long = null, | |
public bool $required = false, |
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 asciiTable(array $rows, array $columns, ?callable $mapper = null): string | |
{ | |
if ($mapper === null) { | |
$mapper = function (string $column, $value) { | |
return $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
@echo off | |
if "%PHP%"=="" ( | |
echo %%PHP%% is NOT defined | |
exit /b | |
) | |
%PHP% %* |
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 php | |
<?php | |
declare(strict_types=1); | |
const PHPS = 'phps'; | |
const COMMENT = '#'; | |
const BANG = '!'; | |
if (empty($argv[1])) { | |
throw new RuntimeException("Missing php file"); |
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
New-NetFirewallRule -DisplayName "Block Microsoft Edge News Feed by IP" -RemoteAddress "204.79.197.203" -Action "Block" -Direction "Outbound" -Package "S-1-15-2-3624051433-2125758914-1423191267-1740899205-1073925389-3782572162-737981194" |
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 fork($program, ...$args): int | |
{ | |
if (strtoupper(php_uname('s')) === 'WINDOWS NT') { | |
$cmd = [ | |
'powershell.exe', | |
'-Command', | |
'$proc', | |
'=', |
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 php | |
<?php | |
function getDownloadPathWindows() | |
{ | |
$home = getenv('HOMEDRIVE') . getenv('HOMEPATH'); | |
if (!is_dir($home)) { | |
throw new RuntimeException("No home folder $home"); | |
} | |
return "$home/Pictures/Bing"; |
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
set autoident | |
set tabsize 4 | |
set tabstospaces | |
set multibuffer | |
set smarthome | |
set whitespace "»·" | |
set const | |
set historylog | |
set mouse | |
set poslog |
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
# http://stackoverflow.com/a/11426261 | |
cd repository | |
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- path/to/file_or_folder > patch | |
cd ../another_repository | |
git am < ../repository/patch |
NewerOlder