Skip to content

Instantly share code, notes, and snippets.

View j3j5's full-sized avatar
🤷‍♂️

Julio J. j3j5

🤷‍♂️
View GitHub Profile
@jrmadsen67
jrmadsen67 / gist:bd0f9ad0ef1ed6bb594e
Last active February 15, 2022 08:41
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@phpdude
phpdude / example.js
Last active June 9, 2018 20:14
PhantomJS: hellper for writing scripts waiting full page load (DOMContentLoaded event)
var system = require("system");
var url = system.args[1];
require('./phantom-full-load')(phantom, url, function (page, logs) {
logs.forEach(function (i) {
console.log('> ' + i);
});
result = page.evaluate(function () {
return $('body *').attr('class');
@iolson
iolson / .env.example
Created September 17, 2015 22:14
GitLab CI Laravel 5.1.*
DB_HOST=mysql
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
@Thinkscape
Thinkscape / EffectiveUrlMiddleware.php
Last active October 4, 2022 18:30
getEffectiveUrl() replacement for Guzzle 6.*
<?php
namespace Thinkscape\Guzzle;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class EffectiveUrlMiddleware
{
/**
* @var Callable
@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
{
/**
@ndarville
ndarville / webm.md
Last active September 30, 2023 18:56
4chan’s guide to converting GIF to WebM - https://boards.4chan.org/g/res/41212767

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@EdgeCaseBerg
EdgeCaseBerg / log_query.php
Last active September 14, 2016 21:00
Log SQL queries from WordPress
<?php
// in wordpress theme: functions.php add this in
function log_sql_queries($text_query){
/* //Uncomment me if you want a lot of info about where the sql query comes from and what action started it off
$traces = debug_backtrace();
$i = 0;
foreach ($traces as $tobj => $trace) {
if($trace['function'] == 'do_action'){
@martijnvermaat
martijnvermaat / ssh-agent-forwarding-screen.md
Created December 21, 2013 15:06
SSH agent forwarding and screen

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

@tortuetorche
tortuetorche / 01.FiniteAuditTrail.README.md
Last active May 28, 2022 03:39
FiniteAuditTrail Trait For Laravel 4 with Example. Support for keeping an audit trail for any state machine, borrowed from the Ruby StateMachine audit trail gem.

FiniteAuditTrail Trait

Support for keeping an audit trail for any state machine, borrowed from the Ruby StateMachine audit trail gem. Having an audit trail gives you a complete history of the state changes in your model. This history allows you to investigate incidents or perform analytics, like: “How long does it take on average to go from state a to state b?”, or “What percentage of cases goes from state a to b via state c?”

Requirements

  1. PHP >= 5.4
  2. Laravel 4 framework