Skip to content

Instantly share code, notes, and snippets.

View adampatterson's full-sized avatar
:octocat:

Adam Patterson adampatterson

:octocat:
View GitHub Profile
<IfModule mod_mime.c>
# Audio
AddType audio/mp4 m4a f4a f4b
AddType audio/ogg oga ogg
# JavaScript
# Normalize to standard type (it's sniffed in IE anyways):
# http://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js
@adampatterson
adampatterson / Console Log ACF
Last active February 24, 2016 05:15
Working with ACF Custom data
<? $data = get_fields();?>
<script>
console.log(<?= json_encode($data) ?>)
</script>
$this->app['request']->server->set('HTTPS', $this->app->environment() != 'local');
@adampatterson
adampatterson / Handler.php
Last active April 23, 2019 12:36
Laravel 5.2 custom 500 error page
# /app/Exceptions/Handler.php
# use Symfony\Component\Debug\Exception\FlattenException;
# public function render($request, Exception $e)
$exception = FlattenException::create($e);
$statusCode = $exception->getStatusCode($exception);
if ($statusCode === 404 or $statusCode === 500 and app()->environment() == 'production') {
gulp.task('cacheBuster', function(cb){
//new Date().getTime()
fs.writeFile('config/cacheBuster.php', '<?php return ' + new Date().getTime() + ';', cb);
});
@adampatterson
adampatterson / routes-and-controllers.php
Created October 11, 2016 20:41
Laravel controllers with
<?
/*
I am using route caching that prevents me from using closures, but even then I don't see why I can't choose to pass static information to a controller without using route parameters.
For example, My project has an umber of redirects in it, and rather than loading up 40 domains with redirect DNS entries that only I have access to.
I have a helper controller to do this so that my team may make entries.
I am running 40 unique sites out of one Laravel instance to keep my maintenance low. 40 sites x about 25 redirects is a lot of DNS entries.
*/
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
@adampatterson
adampatterson / wp-multisite-cron.php
Last active January 25, 2017 20:56
Call WordPress CRONs properly, removes event based cron functionality.
<?php
/*
* Since WordPress is event driven, the wp-cron's will run on every single page load.
* This means if you have a larger WordPress site your doing a lot of extra leg work for noreason.
* This fixes that on Multsites
*
* Add this file to the root of your WordPress site and then add define('DISABLE_WP_CRON', 'true');
* to your wp-config.php
*
* Make sure that you create a true CRON job that will call your site URL via curl
@adampatterson
adampatterson / .babelrc
Created June 22, 2017 19:47
Using Mix to build React, Includes Object Spread
{
"plugins": [
"transform-object-rest-spread",
"transform-class-properties",
"transform-react-constant-elements",
"transform-decorators-legacy"
],
"presets": [
["es2015", {"modules": false}],
"react"
@adampatterson
adampatterson / sample.php
Created October 18, 2017 00:50
Whoops PHP Storm Config
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{