Skip to content

Instantly share code, notes, and snippets.

View macocci7's full-sized avatar
😊
good

macocci7 macocci7

😊
good
View GitHub Profile
@macocci7
macocci7 / Dir.php
Created May 26, 2024 09:15
[Laravel Prompts] File Selector (ファイル選択)
<?php
namespace MyLib;
class Dir
{
/**
* Returns all entries in the directory as RecursiveDirectoryIterator
* ディレクトリ内の全エントリーをRecursiveDirectoryIteratorで返す
*
@macocci7
macocci7 / takeScreenshotAndHtmlOfSelectedNode.php
Last active May 14, 2024 02:47
chrome-php/chrome 指定要素のみのスクリーンショット&HTML取得 (Taking Screenshot and Html of Selected Node)
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use HeadlessChromium\BrowserFactory;
use HeadlessChromium\Clip;
use HeadlessChromium\Dom\Dom;
use HeadlessChromium\Dom\Selector\CssSelector;
use HeadlessChromium\Page;
use headlessChromium\Utils;
@macocci7
macocci7 / benchmarkAddArrayEelements.php
Last active December 17, 2023 12:10
Script to benchmark the performance of adding array elements (配列要素追加処理のベンチマークスクリプト)
<?php
function benchmark(string $name, Closure $callback)
{
$start = microtime(true);
$callback();
$time = microtime(true) - $start;
echo sprintf(
"%24s =>\tTime: %.6f sec.\n",
$name,
@mlocati
mlocati / exceptions-tree.php
Created March 9, 2017 10:58
Throwable and Exceptions tree
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');