Skip to content

Instantly share code, notes, and snippets.

View spresnac's full-sized avatar
:octocat:
Doing great stuff 🥂

Sascha Presnac spresnac

:octocat:
Doing great stuff 🥂
View GitHub Profile
@spresnac
spresnac / update_globals.bat
Created March 7, 2024 19:58
Daily update globals
composer selfupdate && composer global update && npm -g i npm npm-check-updates && ncu -g
@spresnac
spresnac / insights.php
Created November 7, 2022 08:38
Default laravel excludes for phpinsights
/**
* In your config/insights.php
*/
// ...
'exclude' => [
'app/Actions/Fortify',
'app/Actions/Jetstream',
'app/Console/Kernel.php',
@spresnac
spresnac / only_unique_joins.php
Created July 16, 2020 13:07
Prevent the Builder to execute with duplicate joins (causes mariadb error)
/** @var Builder $result */
// try to prevent duplicate joins that will cause an error on execute
$result->getQuery()->joins = collect($result->getQuery()->joins)->unique('table')->toArray();
<?php
namespace App\Traits;
use App\Model\BaseModel;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
@spresnac
spresnac / RealBoolean.php
Last active June 3, 2019 08:57
A rule to check passing boolean-like values in validation requests
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
/**
* Class RealBoolean
*
* To check on several values that can be interpreted as 'boolean'
@spresnac
spresnac / PaginationHelper.php
Created May 20, 2019 13:24
Laravel styled pagination for collections
<?php
namespace App\Helper;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;
class PaginationHelper
{
/**
@spresnac
spresnac / gist:2172fd336c596f0d4c4d8e223645ca99
Created February 17, 2017 09:28
js-tablesorter: Handle german date format to sort correctly
$.tablesorter.addParser({
id: 'germanDate',
is: function(s) {
return false;
},
format: function(s) {
var dateMatches = s.match(/([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{2,4}) ([0-9]{1,2}):([0-9]{1,2})/i);
return dateMatches[3]+dateMatches[2]+dateMatches[1]+dateMatches[4]+dateMatches[5];
},
// set type, either numeric or text
@spresnac
spresnac / phpcs.bat
Created January 2, 2017 13:11
phpcs batch for Windows
@echo off
"D:\php-7.0.13-Win32-VC14-x64\php.exe" "D:\www\phpcs.phar" %1 %2 %3 %4 %5 %6 %7 %8 %9
PHPUnit 4.0.17 by Sebastian Bergmann.
Configuration read from /media/sascha/Acer/zend/Apache2/htdocs/pimf/phpunit.xml
The Xdebug extension is not loaded. No code coverage will be generated.
.........................................EEEEEE................ 63 / 437 ( 14%)
.................EEEEE.EFEEEE.............E.................... 126 / 437 ( 28%)
...........S.S.S.S..........................E...FEEEF.EEEEEEEEE 189 / 437 ( 43%)
E..........................................EEEEEE.............. 252 / 437 ( 57%)