Skip to content

Instantly share code, notes, and snippets.

View carbontwelve's full-sized avatar
🎯
Focusing

Simon Dann carbontwelve

🎯
Focusing
View GitHub Profile
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);
<?php
class Auth extends Laravel\Auth {}
/**
* @method static add(string $name, string $source, array $dependencies = array(), array $attributes = array())
* @method static string styles()
* @method static string scripts()
*/
class Asset extends Laravel\Asset {}
class Autoloader extends Laravel\Autoloader {}
class Bundle extends Laravel\Bundle {}
@carbontwelve
carbontwelve / Import.php
Last active January 8, 2016 14:27
Laravel model for wordpress wp_term table
<?php
/* Import.php */
namespace App/Controllers;
use /App/Models/TermTaxonomy;
use /App/Models/Term;
class Import extends BaseController
{
public function index()
{
@carbontwelve
carbontwelve / gist:6363439
Created August 28, 2013 08:16
WordPress Title
<?php
/* This needs some refactoring http://perishablepress.com/perfect-wordpress-title-tags-redux/ */
if (function_exists('is_tag') && is_tag()) {
single_tag_title("Tag Archive for &quot;");
echo'&quot; - ';
} elseif (is_archive()) {
wp_title('');
echo ' Archive - ';
} elseif (is_search()) {
echo 'Search for &quot;'.wp_specialchars($s).'&quot; - ';
<?php
function explodeArrayFunction($input)
{
$array = preg_split('/(\s|[\.,\/])/', $input, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
return array_values($array);
}
function implodeArrayFunction($input)
{
@carbontwelve
carbontwelve / bench.php
Last active December 23, 2015 23:39 — forked from Rican7/bench.php
#!/usr/bin/env php
<?php
/**
* JSON/BSON encoding and decoding benchmark
*
* Now with native serializing!
*
* @copyright 2013 Trevor N Suarez
* @link http://blennd.com/
* @author Trevor Suarez <rican7@gmail.com>
<?php
/**
* TestArrayWalk
*
* This is the code I have used when describing an issue I had with array_walk, closures and referencing $this
* within PHP version 5.3.3.
*
* The original stackoverflow question can be seen here:
* http://stackoverflow.com/questions/19033184/using-this-when-not-in-object-context-error-within-array-walk
*
@carbontwelve
carbontwelve / factorials.php
Created September 27, 2013 15:50
Generates factorial's
<?php
$time_start = microtime(true);
$iterations = 20;
header('Content-Type: text/plain');
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
@carbontwelve
carbontwelve / .bashrc
Created October 1, 2013 08:23
Colour Prompt
# Prompt for user
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
#prompt for root
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
<?php
/*
|--------------------------------------------------------------------------
| Cache Filters
|--------------------------------------------------------------------------
|
| This filter can be attached to a route to easily add a simple caching
| layer.
|
| Use as a before and after filter. When fired after a request the cache