Skip to content

Instantly share code, notes, and snippets.

View whoami15's full-sized avatar
🎯
Focusing

Daryl Ferrer Legion whoami15

🎯
Focusing
View GitHub Profile
@whoami15
whoami15 / CreateGeneralExportFileJob.php
Created May 16, 2024 12:12 — forked from brytey2k/CreateGeneralExportFileJob.php
A simple Laravel job that can help you export data through CSV from a database with millions of rows.
<?php
namespace App\Jobs;
use App\Models\GeneralExport;
use Storage;
class CreateGeneralExportFileJob implements ShouldQueue
{
@whoami15
whoami15 / signoff
Created May 1, 2024 01:22 — forked from dhh/signoff
#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)
@whoami15
whoami15 / macro.md
Created April 30, 2024 03:48 — forked from brunogaspar/macro.md
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

<?php
\Illuminate\Support\Str::macro('extremeSnake', function($value, $delimiter = '_') {
$pattern = <<<'REGEXP'
/
(?<!^) # don't match the beginning of a string
(
(?<=[^\p{Lu}])[\p{Lu}\p{M}]+(?=\p{M}?[^\p{Ll}]\p{M}?\p{L}) # string of upper-case (like an abbreviation)
| (?<=\p{Lu}{2})[\p{Lu}\p{M}](?=\p{M}?\p{Ll}) # the final upper-case in a sequence
| (?<=[^\p{Lu}])[\p{Lu}\p{M}](?=\p{M}?\p{Ll}) # first upper-case in a capitalized sequence

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@whoami15
whoami15 / --usage.php
Created February 14, 2024 00:39 — forked from inxilpro/--usage.php
Simple wrapper for OpenSpout
<?php
// Reading
CsvReader::read($path)->each(function(array $row) {
// Do something with $row
});
// Writing
return CsvWriter::for($data)->writeToHttpFile();
<?php
/**
* Refactor #1:
*/
// Before
if ($user->type === 'admin' || $user->type === 'mod' || $user->type === 'author') {
// Do something.
}
<?php
function memoize($target) {
static $memo = new WeakMap;
return new class ($target, $memo) {
function __construct(
protected $target,
protected &$memo,
) {}

Learning Plan for Test Driven Development (TDD)

These learning resources primarily focus on Test Driven Development (TDD).

  • There is an emphasis on learning using PHP, Laravel and PHPUnit.
  • All these resources are free (at the time of writing)
@whoami15
whoami15 / Info for PHPStorm.md
Created November 20, 2022 11:51 — forked from Pen-y-Fan/Info for PHPStorm.md
PHPStorm Tips, Tricks and setup

PHPStorm

PhpStorm Tips, ticks and standard setup

  1. Tips and Tracks for PHPStorm (PHPStorm Tips and Tricks.md)
  2. Standard setup for PHP projects (Standard.md)