Skip to content

Instantly share code, notes, and snippets.

View paulss's full-sized avatar

Paul Whitehead paulss

  • Strawberry Soup
  • Chichester
View GitHub Profile
@paulss
paulss / gist:3857552
Created October 9, 2012 09:10
recursive order by parent SQL
ORDER BY CASE WHEN parent_id=0 THEN id ELSE parent_id END ASC, id ASC
@paulss
paulss / gist:3853000
Created October 8, 2012 15:05
PHP closure example
<?
//create a closure as its cooler and pass in our pcodes
$temp = function() use ($pcodes) {
$new = array();
//loop through and create new array
foreach($pcodes as $code => $additional) {
$new[] = array('location' => $code, 'additional' => implode(', ', $additional), 'type' => 'postcode');
}
return $new;
@paulss
paulss / gist:3798639
Created September 28, 2012 08:27
get month from integer
date('F', mktime(0,0,0,$i,1));
@paulss
paulss / gist:3666590
Created September 7, 2012 14:17
jQuery on hover/mouseenter/mouseleave
$('a.help').on({
mouseenter: function() {
}, mouseleave: function() {
}
});
@paulss
paulss / brackets.php
Created August 29, 2012 14:37
get content from within brackets
preg_match('/\(([^\)]*)\)/', $get['location'], $matches);
@paulss
paulss / gist:3225563
Created August 1, 2012 09:58
array walk closure to trim each entry
<?
//array walk closure to trim each entry
$array = array('soemthing', 'something else ', ' another ');
array_walk($array, function(&$n) {
$n = trim($n);
});
@paulss
paulss / gist:2028916
Created March 13, 2012 13:54
my testing gist that i made
this si the test