Skip to content

Instantly share code, notes, and snippets.

View tommymarshall's full-sized avatar

Tommy Marshall tommymarshall

View GitHub Profile
@tommymarshall
tommymarshall / Demo.js
Last active August 9, 2017 18:17
Simple Modal in React using react-portal-minimal and styled-components
import React from 'react';
import { TextBlock } from '../../text';
import { Modal } from '../';
class Demo extends React.Component {
state = {
open: false
};
handleOpenModel = () => this.setState({ open: !this.state.open });
@tommymarshall
tommymarshall / RomanNumeralsConverter.php
Created August 25, 2014 19:17
Converts roman numerals to numbers.
<?php
class RomanNumeralsConverter
{
protected static $mappings = [
'I' => 1,
'V' => 5,
'X' => 10,
'L' => 50,
'C' => 100,
@tommymarshall
tommymarshall / ContentfulBuilder.php
Created January 18, 2017 22:50
Contentful Feed Builder
<?php
class ContentfulBuilder {
protected $query;
public function __construct() {
$this->query = new Query;
}
@tommymarshall
tommymarshall / ansible_play.yaml
Created January 6, 2017 22:00
Ansible play for provision server with SSL
---
company: XXX
provider: rackspace
server_os: trusty
server_size: 8G
stack: lamp
httpd_package: apache
database_package: mysql
ssl_test_mode: yes
@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 / nginx.conf
Last active June 10, 2016 23:10
Craft nginx configuration
server {
listen 80;
# route www to non-www
server_name www.clientsite.com;
return 301 $scheme://clientsite.com$request_uri;
}
server {
listen 80 default_server;
server_name clientsite.com;
@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.