Skip to content

Instantly share code, notes, and snippets.

View jeffochoa's full-sized avatar

Jeff Ochoa jeffochoa

View GitHub Profile
@carloshhr
carloshhr / webpack.mix.js
Created January 20, 2018 20:21
Browser Sync configuration on Laravel Mix 5.5
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.browserSync({
proxy: {
target: "www.mygreatsitewillmakemerich.local"
},
files: [
'app/**/*',
'public/**/*',
'resources/views/**/*',
@calebporzio
calebporzio / timer_helpers.php
Last active August 18, 2019 00:07
A simple helper function and macro for timing php scripts and eloquent queries
<?php
// Helper function.
if (! function_exists('timer')) {
function timer($expression)
{
$start = microtime(true);
if ($expression instanceof Closure) {
$expression();
@sileence
sileence / DetectRepeatedQueries.php
Last active October 26, 2023 06:54
Trait to detect repeated queries (i.e. N+1 problem) inside unit tests
<?php
namespace Tests;
use Illuminate\Support\Facades\DB;
trait DetectRepeatedQueries
{
public function enableQueryLog()
{
/*
* WP REST API version 2.0-beta7
* API base url ishttp://www.example.com/wp-json
*
* Reference
* https://wordpress.org/support/topic/new-post-with-image
*/
/*
* Get Guzzle HTTP Client. That client has been authenticated.
*/
@dimsemenov
dimsemenov / vcl-regex-cheat-sheet
Last active March 12, 2022 19:01
Regular expression cheat sheet for Varnish (.vcl). Examples of vcl regexp. Found here http://kly.no/varnish/regex.txt (by Kristian Lyngstøl)
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"
@JeffreyWay
JeffreyWay / laravel.js
Last active April 6, 2024 20:12
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {