Skip to content

Instantly share code, notes, and snippets.

<?php
namespace Tests\Project;
use RecursiveCallbackFilterIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use SplFileInfo;
use Tests\Constraints;
use Tests\TestCase;
<?php
use Illuminate\Contracts\Debug\ExceptionHandler;
trait InteractsWithExceptionReports
{
protected function expectsExceptionReport(
string|Closure $expected,
?string $message = null
) {
@inxilpro
inxilpro / http_response_code.php
Created August 23, 2013 15:08
Polyfill for PHP 5.4's http_response_code() function.
<?php
if (!function_exists('http_response_code')) {
function http_response_code($code = null)
{
static $defaultCode = 200;
if (null != $code) {
switch ($code) {
case 100: $text = 'Continue'; break; // RFC2616
<?php
namespace App\Support;
use InvalidArgumentException;
class Bytes
{
// Most modern systems use base-1000 rather than base-1024 for file size now
protected const BASE = 1000;
<?php
$value = '4 mb';
$units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
$aliases = ['k' => 1, 'kiB' => 1, 'm' => 2, 'MiB' => 2, 'g' => 3, 'GiB' => 3, 't' => 4, 'TiB' => 4, 'PiB' => 5, 'EiB' => 6, 'ZiB' => 7, 'YiB' => 8];
preg_match('/([0-9,.]+)\s*([a-z]+)/i', $value, $matches);
[$_, $size, $unit] = $matches;
@inxilpro
inxilpro / Builder.js
Created December 3, 2022 01:56
expo sqlite ORM (work in progress)
import Grammar from './Grammar.js';
import Connection from './Connection.js';
const operators = [
'=', '<', '>', '<=', '>=', '<>', '!=', '<=>',
'like', 'like binary', 'not like', 'ilike',
'&', '|', '^', '<<', '>>', '&~', 'is', 'is not',
'rlike', 'not rlike', 'regexp', 'not regexp',
'~', '~*', '!~', '!~*', 'similar to',
'not similar to', 'not ilike', '~~*', '!~~*',
@inxilpro
inxilpro / Laravel.xml
Created October 19, 2022 21:33
Laravel PhpStorm Code Style
<code_scheme name="Laravel" version="173">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="USE_TAB_CHARACTER" value="true" />
<option name="KEEP_INDENTS_ON_EMPTY_LINES" value="true" />
</value>
</option>
<option name="LINE_SEPARATOR" value="&#10;" />
<CssCodeStyleSettings>
<option name="HEX_COLOR_LOWER_CASE" value="true" />
<?php
use Illuminate\Support\Collection;
class Snapshots
{
protected static ?self $instance = null;
public static function instance(): self
{
<div class="tailwind" x-data="{ age: 0, name: '', coppa: false }">
<div class="border rounded-lg my-12 max-w-md">
<div class="p-6">
<h1
class="mt-0"
x-show="$wizard.current().title !== ''"
x-text="$wizard.current().title"
></h1>
<form x-data="{ name: '', age: null, coppa: false }">
<h1 x-text="$wizard.title"></h1>
<div x-wizard:step>
This step can be completed without doing anything. It's
just informational.
</div>
<div