Skip to content

Instantly share code, notes, and snippets.

Avatar
🐼
beary busy

Tom Witkowski Gummibeer

🐼
beary busy
View GitHub Profile
View HasHashId.php
<?php
namespace App\Eloquent\Concerns;
use Illuminate\Database\Eloquent\Model as IlluminateModel;
use Illuminate\Support\Arr;
use Vinkla\Hashids\Facades\Hashids;
trait HasHashId
{
View backup-periods.php
<?php
use Carbon\Carbon;
use Carbon\CarbonPeriod;
use Illuminate\Support\Collection;
$period = collect(CarbonPeriod::since(Carbon::parse('-1year'))->days(1)->until(Carbon::now()))
->concat(CarbonPeriod::since(Carbon::parse('-1week'))->hours(1)->until(Carbon::now()))
->concat(CarbonPeriod::since(Carbon::parse('-1day'))->minutes(30)->until(Carbon::now()));
View QueryBuilderWhereOperatorRule.php
<?php
namespace App\PHPStan\Rules;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\DB;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
View BagException.php
<?php
namespace App\Exceptions;
use ArrayIterator;
use Closure;
use Countable;
use Exception;
use Illuminate\Support\Collection;
use IteratorAggregate;
View AssertableJsonResourceAssertions.php
<?php
namespace Tests\Asserts;
use App\Domain\Stock\Enum\StocktakingStatus;
use App\Domain\Stock\Resource\StorageBatchResource;
use Carbon\Carbon;
use DateTimeInterface;
use Illuminate\Testing\Fluent\AssertableJson;
use OutOfBoundsException;
View codewars.52724507b149fa120600031d.php
<?php
function number2words(int $number): string
{
if ($number < 20) {
return ones2words($number);
} elseif ($number < 100) {
return tens2words($number);
} elseif ($number < 1000) {
return hundreds2words($number);
View CreateTodoRequest.php
<?php
namespace JustSteveKing\Transporter;
use Illuminate\Http\Client\PendingRequest;
class CreateTodoRequest extends Request
{
protected string $method = 'POST';
protected string $baseUrl = 'https://jsonplaceholder.typicode.com';
View HasHashId.php
<?php
namespace App\Eloquent\Concerns;
use Illuminate\Database\Eloquent\Model as IlluminateModel;
use Illuminate\Support\Arr;
use Vinkla\Hashids\Facades\Hashids;
trait HasHashId
{
View serviceworker.js
import {registerRoute} from 'workbox-routing';
import {StaleWhileRevalidate} from 'workbox-strategies';
import {CacheableResponsePlugin} from 'workbox-cacheable-response';
import {CacheFirst} from 'workbox-strategies';
import {ExpirationPlugin} from 'workbox-expiration';
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
View clean_macos.sh
# clear system caches
sudo rm -rf /Library/Caches/*
sudo rm -rf /System/Library/Caches/*
sudo rm -rf ~/Library/Caches/*
# clear dns cache
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# clear google chrome cache