Skip to content

Instantly share code, notes, and snippets.

View tabacitu's full-sized avatar

Cristian Tăbăcitu tabacitu

View GitHub Profile
@tabacitu
tabacitu / gist:dbcfd71375e72c857474
Last active April 20, 2020 09:05
Tabacitu Laravel Package Service Provider boilerplate code
<?php
namespace League\Skeleton;
use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router;
class SkeletonServiceProvider extends ServiceProvider
{
/**
@tabacitu
tabacitu / PermissionMiddleware.php
Created January 29, 2017 15:40
Laravel Role and Permission Middlewares
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class PermissionMiddleware
{
/**
@tabacitu
tabacitu / CreatedByTrait.php
Created September 3, 2017 05:38
CreatedByTrait
<?php namespace App\Models\Traits;
use Illuminate\Database\Eloquent\Model;
trait CreatedByTrait {
/**
* Stores the user id at each create & update.
*/
public function save(array $options = [])
@tabacitu
tabacitu / backpack.stack.css
Created September 20, 2018 07:47
Backpack overlay that makes AdminLTE match the Stack Multi-Purpose HTML Template
/* ------------------------------------------ */
/* ------- Backpack Stack Overlay ------------ */
/* ------------------------------------------ */
/* This file brings some subjective improvements to the AdminLTE style, to match the style provided by the Stack HTML Template. */
.sidebar-menu>li>a>.fa,
.sidebar-menu>li>a>.glyphicon,
.sidebar-menu>li>a>.ion {
margin-right: 5px;
}
@tabacitu
tabacitu / SolutionA.php
Created October 25, 2018 09:13
Proposal MonsterCrudConfiguration files
<?php
namespace App\AdminPanel\Configurations;
use Illuminate\Http\Request;
class MonsterCrudConfiguration {
public static $model = 'App\Models\Monster';
public static $entityNameSingular = 'monster';
@tabacitu
tabacitu / .zshrc
Last active December 22, 2020 12:19
Quickly create a Backpack Demo, serve it with Laravel Valet, open it with Sublime Text and Brave Browser on Mac OS X
# alias to the subl command
# for it to work, you need to create a symlink to the subl command somewhere in the PATH
# ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
alias sublime='subl'
# function to open the current directory in the browser, served by Laravel Valet
safari() {
open 'http://'$(basename $(pwd))'.test/';
}
@tabacitu
tabacitu / ssh.sql
Created December 29, 2019 10:20
MySQL Dump Large Table Entries In Chunks
## This process can be used to export a huge DB table. I've used it to export a 24GB table,
## containing 146 million records, into chunks of 25 million records, each chunk taking up aprox 500mb each.
##
## Of course, USERNAME, DATABASENAME and TABLENAME need to be replaced with actual values.
## First thing when it's run, it'll ask for that user's password.
##
## COMMAND BREAKDOWN:
## mysqldump - u [username] -p [databasename] [tablename]
## --no-create-info # don't include CREATE and DROP statements in the dump
## --where="" # filter the dumped rows
@tabacitu
tabacitu / app\Http\Controllers\Admin\InvoiceCrudController.php
Last active December 31, 2020 08:55
Invoice Manager example - with repeatable field used to create and edit InvoiceItems
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\InvoiceRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
/**
* Class InvoiceCrudController
@tabacitu
tabacitu / howto.md
Last active December 16, 2020 18:47
How to Deploy a Laravel+Backpack project on Laravel Vapor

Note: HUGE thanks to @mwisner, he's the one who figured out the solution here, and put together the first solution here. This is just a rephrasing of his solution, as a step-by-step guide that I think will apply to most Backpack projects.

How to deploy a Laravel+Backpack project on Vapor

Step 1. Follow the Vapor docs to install vapor, vapor-core and maybe even vapor-ui. Normally you do that by running vapor init.


@tabacitu
tabacitu / README.md
Last active May 28, 2021 14:48
Awesome Protocol Handlers - Open your Code Editor when Clicking Specific Links

How do you make sublime:// or vscode:// links actually open files in that editor?

Rephrased: you'd expect an URL like subl://open/?url=file:///etc/passwd&line=10&column=2 to open in... Sublime Text. Right? Well that doesn't happen by default, because that protocol doesn't exist, you need a new protocol handler. This article is here to help you do just that.

Unfortunately... there's never been a single source, where you can learn how to do that no matter what OS or editor you use. Until now. Please help us make this the source of information on this topic, we're all tired of searching for this 😀

Windows Mac OS Linux
Visual Studio Code ??? ??? ???
Sublime Text ??? ??? ???