Skip to content

Instantly share code, notes, and snippets.

View ryanscherler's full-sized avatar

Ryan Scherler ryanscherler

View GitHub Profile
@ryanscherler
ryanscherler / ResizeImageListener.php
Last active June 5, 2021 08:33
Add Image Resizing to Jigsaw
<?php
namespace App\Listeners;
use TightenCo\Jigsaw\Jigsaw;
use App\Utilities\ResizeImageUtility;
class ResizeImageListener
{
public function handle(Jigsaw $jigsaw)
@ryanscherler
ryanscherler / web.php
Created August 27, 2018 17:34
Lumen Catch-all Route (for SPA etc.)
<?php
// Catch all route for SPA
$router->get('[{path:.*}]', function ($path = null) use ($router) {
return $path;
});
@ryanscherler
ryanscherler / index.php
Created November 10, 2017 21:41
Craft 3 Multisite dynamic mapping based on .env
<?php
/**
* Craft web bootstrap file
*/
// Set path constants
define('CRAFT_BASE_PATH', dirname(__DIR__));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');
// Load Composer's autoloader
@ryanscherler
ryanscherler / disable_strict_mode.cnf
Created May 15, 2017 23:06
MySQL Disable Strict Mode
[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
@ryanscherler
ryanscherler / fileUpload.php
Created May 12, 2017 03:18
FS-App File Upload snippet.
// File Upload
if (Input::hasFile('files')) {
$files = Input::file('files');
$path = public_path().'/_uploads/'.$project->id.'/';
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0775, true, true);
}
foreach ($files as $file) {
// Move to public/uploads
$fileName = $file->getClientOriginalName();
@ryanscherler
ryanscherler / my.cnf
Created May 9, 2017 17:04
Craft 2: remove the ONLY_FULL_GROUP_BY option from sql_mode. That will change GROUP BY behavior back to its pre-MySQL 5.7.5 behavior.
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
<?php
class ProcessWireValetDriver extends BasicValetDriver
{
private $possibleDirectories = [
'', // PW in root, do not remove except you're sure you never use it
'/dist',
'/public'
];
@ryanscherler
ryanscherler / env.helper.php
Last active January 24, 2017 07:17
Gets the value of an environment variable. Supports boolean, empty and null.
<?php
if ( ! function_exists('env')) {
/**
* Gets the value of an environment variable. Supports boolean, empty and null.
*
* @author Taylor Otwell / Laravel
* @param string $key
* @param mixed $default
* @return mixed
*/
@ryanscherler
ryanscherler / php-openssl.md
Last active August 16, 2018 20:06
Use Homebrew PHP with OpenSSL instead of SecureTransport
@ryanscherler
ryanscherler / CustomCollection.php
Last active December 15, 2018 20:41
Extends Laravel collections to convert array items to a collection recursively.
<?php
namespace App\Support\Collection;
use \Illuminate\Support\Collection;
class CustomCollection extends Collection {
/**
* Converts array items to a collections recursively.