Skip to content

Instantly share code, notes, and snippets.

Jeff Ochoa jeffochoa

Block or report user

Report or block jeffochoa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jeffochoa
jeffochoa / ProgressBarCallback.php
Last active May 28, 2019
ProgressBar callback trait for Laravel commands
View ProgressBarCallback.php
<?php
namespace App\commands;
trait ProgressionBarOutput
{
public function runProcess(\Countable $countable, callable $callback)
{
$bar = $this->output->createProgressBar(count($countable));
$bar->start();
@jeffochoa
jeffochoa / .php_cs
Last active May 15, 2019 — forked from jannejava/.php_cs
PHPCS Fixer for VSCode and Laravel
View .php_cs
<?php
return PhpCsFixer\Config::create()
->setRules(array(
'@PSR2' => true,
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
'braces' => true,
@jeffochoa
jeffochoa / Errors.js
Last active Sep 27, 2019
Vue Form and Error validator (Laracasts)
View Errors.js
class Errors {
/**
* Create a new Errors instance.
*/
constructor() {
this.errors = {};
}
/**
@jeffochoa
jeffochoa / event.js
Created Mar 4, 2018
Vue event dispatcher
View event.js
class Event {
constructor() {
this.vue = new Vue();
}
fire(event, data = null) {
this.vue.$emit(event, data);
}
listen(event, callback) {
@jeffochoa
jeffochoa / event.js
Last active Jul 11, 2019
VueJs global event dispatcher
View event.js
class Event {
constructor() {
this.vue = new Vue();
}
fire(event, data = null) {
this.vue.$emit(event, data);
}
listen(event, callback) {
@jeffochoa
jeffochoa / vcl-regex-cheat-sheet
Created Dec 21, 2017 — forked from dimsemenov/vcl-regex-cheat-sheet
Regular expression cheat sheet for Varnish (.vcl). Examples of vcl regexp. Found here http://kly.no/varnish/regex.txt (by Kristian Lyngstøl)
View vcl-regex-cheat-sheet
Regular expression cheat sheet for Varnish
Varnish regular expressions are NOT case sensitive. Varnish uses POSIX
regular expressions, for a complete guide, see: "man 7 regex"
Basic matching:
req.url ~ "searchterm"
True if req.url contains "searchterm" anywhere.
req.url == "searchterm"
@jeffochoa
jeffochoa / Response.php
Last active Nov 12, 2019
Laravel HTTP status code
View Response.php
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@jeffochoa
jeffochoa / img-async.html
Created Oct 13, 2017
Chrome image async API
View img-async.html
<!-- if possible: -->
<!-- the decode for this image may be deferred -->
<img async=on src="space-cats.jpg">
<!-- the decode for this image should not be deferred -->
<img async=off src="space-dogs.jpg">
<!-- the browser is free to do what it feels is best for the user -->
<img src="space-pizza.jpg">
@jeffochoa
jeffochoa / 1.ProcessClass.php
Last active Oct 31, 2019
Understanding Laravel pipelines
View 1.ProcessClass.php
<?php
namespace App\Features;
use App\Features\FirstTask;
use App\Features\SecondTask;
use Illuminate\Pipeline\Pipeline;
// *Naming things is hard* ... So, this is a class called `ProcessClass` that `run()` some text ¯\_(ツ)_/¯
class ProcessClass
@jeffochoa
jeffochoa / timer_helpers.php
Created Jul 31, 2017 — forked from calebporzio/timer_helpers.php
A simple helper function and macro for timing php scripts and eloquent queries
View timer_helpers.php
<?php
// Helper function.
if (! function_exists('timer')) {
function timer($expression)
{
$start = microtime(true);
if ($expression instanceof Closure) {
$expression();
You can’t perform that action at this time.