Skip to content

Instantly share code, notes, and snippets.

View carbontwelve's full-sized avatar
🎯
Focusing

Simon Dann carbontwelve

🎯
Focusing
View GitHub Profile
@carbontwelve
carbontwelve / routes.php
Created February 19, 2014 10:28
How to check if a route exists in laravel4
<?php
$routeExists = Route::getRoutes()->hasNamedRoute('route.name');
dd($routeExits);
@carbontwelve
carbontwelve / Snippets.php
Created February 25, 2014 15:42
Laravel CSRF Before filter on post
<?php
// CSRF Protection
$this->beforeFilter('csrf', array('on' => 'post'));
<?php
/*
Plugin Name: Skeleton Widget
Description: A widget example for the widget article at photogabble.co.uk
*/
class Carbontwelve_Skeleton_Widget extends WP_Widget {
/**
* Register widget with WordPress.
<?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 / 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');