Skip to content

Instantly share code, notes, and snippets.

View gsdevme's full-sized avatar

Gavin Staniforth gsdevme

View GitHub Profile
@gsdevme
gsdevme / db.php
Created August 20, 2011 19:24
Query Setup
<?php
try {
$return = ( bool ) !preg_match('/(^INSERT|^DELETE|^UPDATE)/i', $query);
$stmt = $this->_pdo->prepare($query);
if ($args->count() !== 0) {
for ($args; $args->valid(); $args->next()) {
$value = $args->current();
$data = $this->_dataType($value);
@gsdevme
gsdevme / gist:1394745
Created November 26, 2011 00:28
test
<?php
class foo
{
}
@gsdevme
gsdevme / tooltips
Created December 4, 2011 00:39
Tooltips from title="" attributes
(function(doc, undefined){
var e = doc.querySelectorAll('a.tooltip'), s;
if(e !== undefined){
for(i=0;i<e.length;++i){
s = document.createElement('span'),
s.className='tooltip',
s.innerHTML = e[i].getAttribute('title'),
s.style.padding = '0 15px';
<?php
class System
{
public static function run()
{
$args = func_get_args();
if (!empty($args)) {
(function(window,document,undefined){
var url,l;
el=document.getElementsByClassName('grabHolidayImages');
if(el!=undefined){
l=el.length;
for(i=0;i<l;++i){
url = el[i].getAttribute('title');
(function(window,document,undefined){
var url,l;
el=document.getElementsByClassName('grabHolidayImages');
if(el!=undefined){
l=el.length;
for(i=0;i<l;++i){
url = el[i].getAttribute('title');
@gsdevme
gsdevme / gist:2048978
Created March 16, 2012 07:14
Quick app() function for PHP 5.2 with slim
<?php
require 'Slim/Slim.php';
function app()
{
static $app;
if(gettype($app) != 'object'){
$app = new Slim();
var fs = require('fs');
function processWatch(file, event) {
fs.stat(file, function(error, stat){
if(error === null){
switch(event){
case 'rename':
// has it actually been changed or is it a node false positive (stupid node bug)
if(stat.ctime.toString() != stat.mtime.toString()){
console.log(file + ' has actually been renamed');
var fs = require('fs');
function processWatch(file, event) {
fs.stat(file, function(error, stat){
if(error === null){
switch(event){
case 'rename':
// has it actually been changed or is it a node false positive (stupid node bug)
if(stat.ctime.toString() != stat.mtime.toString()){
console.log(file + ' has actually been renamed');
@gsdevme
gsdevme / ipv6-mysql.php
Created April 2, 2012 04:52
Shit for handling IPv6 & mysql storage
<?php
/**
* Shit for handling IPv6 & mysql storage, @gsphpdev
* Bloody headache... remember this Gavin!
*/
/**
* Only PHP 5.4+ has this function so need to add one if not