Skip to content

Instantly share code, notes, and snippets.

View scrubmx's full-sized avatar
🏴‍☠️

Jorge González scrubmx

🏴‍☠️
View GitHub Profile
<?php
namespace App\Models\Traits;
use LogicException;
trait Immutables
{
/**
* Set a given attribute on the model.
@scrubmx
scrubmx / hosts.csv
Created May 8, 2019 22:35
Spam domain list
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
host
0-mail.com
001.igg.biz
027168.com
0815.ru
0815.ry
0815.su
0845.ru
0box.eu
0clickemail.com
@scrubmx
scrubmx / localStorage.js
Last active June 22, 2023 15:12
Helper functions for localStorage. Manages serialization (serialize/deserialize of objects and arrays)
export default LocalStorage = {
/**
* Determine if browser supports local storage.
*
* @return {boolean}
*/
isSupported() {
return typeof Storage !== 'undefined';
},
@scrubmx
scrubmx / AppServiceProvider.php
Created July 5, 2016 04:47
Register itsgoingd/clockwork only in local environment.
<?php
namespace App\Providers;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Support\ServiceProvider;
use Clockwork\Support\Laravel\ClockworkMiddleware;
use Clockwork\Support\Laravel\ClockworkServiceProvider;
class AppServiceProvider extends ServiceProvider
@scrubmx
scrubmx / MyTest.php
Created March 1, 2022 14:58
Assert exception was reported by Laravel (useful for testing code inside rescue)
<?php
use Tests\TestCase;
class MyTest extends TestCase
{
/**
* Sets up an expectation for an exception to be reported by the code under test.
*/
protected function expectReportedExceptionMessage(string $message): static
@scrubmx
scrubmx / accordion.js
Last active October 10, 2021 17:16
Simple jQuery Accordion implementation for <dl> element
// Accordion - Container
var $listContainer = $('dl.description-list');
$listContainer.on('click', 'dt:not(.active)', function(){
$listContainer.find('dt.active').removeClass('active');
$listContainer.find('dd').slideUp();
$(this).addClass('active').next('dd').slideDown();
});
$listContainer.on('click', 'dt.active', function(){
@scrubmx
scrubmx / AuthController.php
Last active September 15, 2021 19:45
Laravel Sanctum Authentication
<?php
namespace App\Http\Controllers\Api;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
<?php
namespace App\Models\Traits;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
trait Sluggable
{
/**
@scrubmx
scrubmx / sublime-phpcs.md
Last active June 27, 2021 14:14
Setup Phpcs for Sublime Text

Setup Phpcs for Sublime Text

This plugin adds PHP CodeSniffer, PHP Code Beautifier and Fixer, PHP Coding Standards Fixer, the PHP Linter, PHP Mess Detector, Scheck support to Sublime Text.

For more information about this plugin such as features, installation requirements etc, please see: http://benmatselby.github.io/sublime-phpcs

Prerequisites

  • Download and install composer
curl -sS https://getcomposer.org/installer | php 
@scrubmx
scrubmx / mysql_dump_migration.php
Created December 26, 2014 23:17
Import mysql dump as laravel migration
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePostalCodesTable extends Migration {
/**
* Run the migrations.
*