Skip to content

Instantly share code, notes, and snippets.

hamakn /
Created March 15, 2019 11:00
gRPC Code and HTTP Status Code
brunogaspar /
Last active January 5, 2023 15:47
Recursive Laravel Collection Macros


If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.


bgarrant /
Last active September 30, 2022 08:08
How to Switch PHP Version in Laravel Valet between PHP 7.1 and PHP 5.6

How to Switch PHP Version in Laravel Valet between PHP 7.1 and PHP 5.6

Valet switch PHP version with these commands

Install PHP 5.6 and switch Valet to PHP 5.6

valet stop
brew unlink php71
brew install php56
brew install php56-mcrypt
croxton /
Last active February 26, 2023 05:57 — forked from leevigraham/Generate ssl certificates with Subject Alt Names on
Generate ssl certificates with Subject Alt Names

Generate ssl certificates with Subject Alt Names on OSX

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

DNS.1   =

Additional FQDNs can be added if required:

gauravtiwari / window-auth-popup.es6.js
Last active July 21, 2022 05:41
Promise based popup window for server oAuth
View window-auth-popup.es6.js
/* global window */
const popup = (url) => {
const windowArea = {
width: Math.floor(window.outerWidth * 0.8),
height: Math.floor(window.outerHeight * 0.5),
if (windowArea.width < 1000) { windowArea.width = 1000; }
if (windowArea.height < 630) { windowArea.height = 630; }
odewahn /
Last active January 30, 2023 00:30
Processing errors with Fetch API

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
View V8JsNodeModuleLoader.php
require_once __DIR__.'/V8JsNodeModuleLoader_FileAccessInterface.php';
require_once __DIR__.'/V8JsNodeModuleLoader_NormalisePath.php';
* Simple Node.js module loader for use with V8Js PHP extension
* This class understands Node.js' node_modules/ directory structure
* and can require modules/files from there.
DarrenN / get-npm-package-version
Last active March 19, 2023 14:20 — forked from yvele/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
View get-npm-package-version
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
derhansen / removeJobsRedisDriver.php
Last active November 10, 2022 17:17
Laravel 5 - remove all jobs from a queue (redis driver)
View removeJobsRedisDriver.php
discordier / gist:ed4b9cba14652e7212f5
Created December 4, 2014 06:23
options for phpStorm @noinspection annotation
View gist:ed4b9cba14652e7212f5