Skip to content

Instantly share code, notes, and snippets.

View tommymarshall's full-sized avatar

Tommy Marshall tommymarshall

View GitHub Profile
@tommymarshall
tommymarshall / Handler.php
Created January 5, 2017 22:49
app/Exceptions/Handler.php contents
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
@tommymarshall
tommymarshall / MetaViewServiceProvider.php
Created June 2, 2016 13:27
Feed meta data values into a view only once based on a route (right now, every time a view is called it gets overwritten) ie. Want to reference in my layouts.base {{ meta.title }}.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class MetaViewServiceProvider extends ServiceProvider
{
public function boot()
{
@tommymarshall
tommymarshall / cleanup.php
Created May 25, 2016 21:39
Resets WordPress posts to a previous revision that does not contain spam links.
<?php
function contains($str, array $arr)
{
foreach($arr as $a)
{
if (stripos($str, $a) !== false) return true;
}
return false;
}
<?php
protected function assertCookie($key, $value)
{
$headers = new Collection($this->response->headers->allPreserveCase());
$cookies = new Collection($headers->get('Set-Cookie', []));
$matches = $cookies->filter(function($raw_cookie) use ($key, $value) {
list($raw_value) = explode('; ', $raw_cookie);
list($set_name, $set_value) = explode('=', $raw_value);
@tommymarshall
tommymarshall / instructions.md
Last active April 21, 2016 16:14
Move WordPress Generated Files to ./thumbnails/ folder

Move WordPress Generated Files to ./thumbnails/ folder

Keeping WordPress Media Library updated even after a server move.

Instructions

  1. Place the move.php script inside of a folder containing images containing both the Original and WordPress auto-generated thumbnails.
  2. Run the script by navigating to it in the browser. All WordPress generated images will be moved to the ./thumbnails/ subfolder, all remaining images in your original folder are original images.
  3. Upload all Original images to your server.
  4. Install Add From Server Plugin to WordPress.
  5. Select all original images within the Add From Server interface and import.
<?php
/*
Template Name: Search
*/
global $paged;
// Search WP stuff
global $post;
$query = isset($_REQUEST['q']) ? sanitize_text_field($_REQUEST['q']) : '';
@tommymarshall
tommymarshall / Feed.php
Created April 5, 2016 14:29
create new instance from class names
<?php
class Feed {
public function items()
{
return $this->feedItems()->map(function($element) {
return $this->createInstance($element['content_type'], $element);
});
}
@tommymarshall
tommymarshall / README.md
Last active March 24, 2016 14:59
Launching a WordPress site

Bringing a Bedrock WordPress site live

Steps

1. Backup Database

Obligatory reminder to plan for the unexpected and give ourselves that peace of mind knowing we can restore what we messed up.

2. Deploy most up-to-date version

From your project repository, ensure that what is on production is up-to-date.

@tommymarshall
tommymarshall / response.txt
Created March 17, 2016 14:20
Sample import log
[2016-03-15 17:21:49] lumen.INFO: Updating: General Manager Housing(862) ||| object(stdClass)#648 (55) {
["id"]=>
int(862)
["created_at"]=>
string(20) "2004-12-22T16:03:10Z"
["updated_at"]=>
string(20) "2016-03-09T16:39:04Z"
["program_organization"]=>
array(1) {
[0]=>
@tommymarshall
tommymarshall / lumen.log
Last active March 15, 2016 15:11
Weird "ÿÿÿÿ" Issue
[2016-03-15 14:02:41] lumen.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught Error: Class 'Symfony\Component\Debug\ExceptionHandlerÿÿÿÿ' not found in /home/vagrant/Projects/Atlantic/fluxx/vendor/laravel/lumen-framework/src/Exceptions/Handler.php:89
Stack trace:
#0 /home/vagrant/Projects/Atlantic/fluxx/app/Exceptions/Handler.php(48): Laravel\Lumen\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#1 /home/vagrant/Projects/Atlantic/fluxx/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(128): App\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /home/vagrant/Projects/Atlantic/fluxx/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(51): Laravel\Lumen\Application->handleUncaughtException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#3 [internal function]: Laravel\Lumen\Applicat