Skip to content

Instantly share code, notes, and snippets.

View ryanscherler's full-sized avatar

Ryan Scherler ryanscherler

View GitHub Profile
<?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 / 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
@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 / 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 / php-openssl.md
Last active August 16, 2018 20:06
Use Homebrew PHP with OpenSSL instead of SecureTransport
@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 / .htaccess
Last active October 8, 2018 20:44
Apache: Force httpS and non www
<IfModule mod_rewrite.c>
RewriteEngine On
AddDefaultCharset UTF-8
# -----------------------------------------------------------------------------------------------
# If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
# -----------------------------------------------------------------------------------------------
RewriteCond %{HTTPS} off
@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 / gatsby-node.js
Created November 30, 2018 17:36
Add PurgeCSS in production for Gatsby
// Add PurgeCSS in production
// See: https://github.com/gatsbyjs/gatsby/issues/5778#issuecomment-402481270
const PurgeCssPlugin = require(`purgecss-webpack-plugin`)
const path = require(`path`)
const glob = require(`glob`)
const PATHS = {
src: path.join(__dirname, `src`)
}
@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.