Skip to content

Instantly share code, notes, and snippets.

View tonyhb's full-sized avatar
🕳️
void

Tony Holdstock-Brown tonyhb

🕳️
void
View GitHub Profile
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('api', '(<action>(/<id>))')
->defaults(array(
'subdomain' => 'api',
'controller' => 'api',
'action' => 'subdomain',
));
// API
Route::set('api', '(<action>(/<subaction>))')
->defaults(array(
'subdomain' => 'api', // api.domain.com
'controller' => 'api',
'action' => 'index',
));
// Load the website
Route::set('welcome', '(<action>(/<subaction>))')
@tonyhb
tonyhb / BCP47 PHP Language Code Array
Created October 19, 2010 23:28
BCP47 (HTML 5 Language Attribute) Language Codes as a PHP Array, taken from http://www.iana.org/assignments/language-subtag-registry
<?php
/**
* These are just the language codes, not regions. This means it only lists en, not en-US, en-CA etc.
* @see http://www.iana.org/assignments/language-subtag-registry
*/
return array
(
"aa" => "Afar",
"ab" => "Abkhazian",
@tonyhb
tonyhb / Kohana 3 Bash Init Script
Created March 13, 2011 20:03
Kohana initialisation bash script: bash script for a new kohana 3 project (with git).
#! /bin/bash
if [[ $1 == '' ]]; then
echo -e "Which folder do you want to initialise the kohana project in?"
read -a dir
dir=${dir[@]}
else
dir=$@
fi
@tonyhb
tonyhb / Kohana Validation
Created March 16, 2011 13:51
When you validate an empty string with the rules not_empty and min_length, validation passes.
public function action_index()
{
echo "<h1>Validation checking</h1>";
$data = array(
"contact_name" => "Name here",
"contact_email" => "admin@example.co.uk",
"company_name" => "Newco Inc",
"password" => "",
"site_name" => "Newco Inc",
@tonyhb
tonyhb / gist:964325
Created May 10, 2011 11:47
Set example from Kohana
public function set($values, $value = NULL)
{
if ($value)
{
// Normalise single field setting to multiple field setting
$values = array($values => $value);
}
if ( ! $values)
return $this;
@tonyhb
tonyhb / configure.sh
Created June 11, 2011 00:08
PHP 5.3.6 Mac OSX Configure, with all the goodies.
# Before installing, install: libjpg, libpng, freetype, t1lib, gettext, icu, libmcrypt,
# This should be in the shell script but I'm mixing homebrew with source downloads, and I can't be assed. I'm half way through already.
sudo ./configure \
--enable-fpm \
--with-libxml-dir=/usr/lib \
--with-openssl \
--with-zlib \
--enable-exif \
--enable-ftp \
@tonyhb
tonyhb / buttons.css
Created June 23, 2011 08:38
Buttons with image backgrounds.
.button, .button span {
display: inline-block;
overflow: visible;
width: auto;
text-decoration: none;
border: 0 none;
outline: 0 none;
padding: 0;
cursor: pointer;
position: relative;
@tonyhb
tonyhb / Helper_Data.php
Last active May 30, 2022 09:25
New prepareIndexdata method for the CatalogSearch Helper in Magento (to integrate with Sphinx)
<?php
// Helper/Data.php
...
public function prepareIndexdata($index, $separator = ' ', $entity_id = NULL)
{
$_attributes = array();
@tonyhb
tonyhb / game.coffee
Created October 30, 2012 22:40
Game State
# Contains the game state in a protected (closure) variable
state : ->
# Our protected variable, only changeable through the setState method
# defined below
_state = 'stopped'
# The state method will (from the 2nd call onwards) only return the
# state.
@.state = ->
_state