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 | |
// ADD THIS TO routes/console.php | |
Artisan::command('lang {key} {lang?}', function ($key, $lang = null) { | |
config([ | |
'filesystems.disks.lang' => [ | |
'driver' => 'local', | |
'root' => lang_path(), | |
], | |
]); |
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 | |
namespace App\Jobs; | |
use App\Models\GeneralExport; | |
use Storage; | |
class CreateGeneralExportFileJob implements ShouldQueue | |
{ |
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 | |
if( ! function_exists('pipe')) { | |
function pipe($payload, $steps = []) | |
{ | |
return app(\Illuminate\Pipeline\Pipeline::class) | |
->send($payload) | |
->through($steps) |
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
// ... ADD TO `web/console.php` | |
Artisan::command('pswd {length?}', function ($length = 24) { | |
dd(implode('', array_map(function () { | |
return chr(random_int(33, 126)); | |
}, array_fill(0, $length, null)))); | |
}); |
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 generatePassword(int $length, bool $lower = true, bool $upper = true, bool $number = true, bool $symbol = true): string | |
{ | |
$sets = [ | |
'lower' => 'abcdefghijklmnopqrstuvwxyz', | |
'upper' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', | |
'number' => '0123456789', | |
'symbol' => '!@#$%^&*()_-=+{}[];:,.<>?', | |
]; | |
$chars = ''; |
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 Pipeline(stages) { | |
if (!(this instanceof Pipeline)) { | |
return new Pipeline(stages); | |
} | |
this.stages = stages || []; | |
} | |
Pipeline.prototype.send = function (payload) { | |
this.payload = payload; | |
return this; |
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 () { | |
let Collection = function (data) { | |
this.data = data || []; | |
}; | |
Collection.make = function (data) { | |
return new Collection(data); | |
}; | |
Collection.prototype = { |
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 pipe($subject) { | |
return new Pipe($subject); | |
} | |
class Pipe implements \Stringable, \ArrayAccess, \IteratorAggregate | |
{ | |
use Transparency; |
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 MemorizeClass | |
{ | |
function __construct( | |
protected $target, | |
protected &$memo, | |
) {} | |
public function __call($method, $params) |
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 benchmark(times, callbacks) { | |
let result = {} | |
Object.entries(callbacks).forEach(([key, value]) => { | |
let thing = {} | |
let start = performance.now() | |
for (let index = 0; index < times; index++) { | |
value() | |
} |