Skip to content

Instantly share code, notes, and snippets.

View gsdevme's full-sized avatar

Gavin Staniforth gsdevme

View GitHub Profile
@gsdevme
gsdevme / index..php
Created July 10, 2012 10:18
Idea for my RESTless framework...
<?php
/**
* None of this works, just an idea.
*
* Idea is a REST based framework for backend of Backbonejs
*
* @twitter gsphpdev
*/
@gsdevme
gsdevme / jsonEncodeFallback.php
Created July 7, 2012 13:29
Creates a fallback for those not using PHP 5.4, however requires you use jsonEncode() not json_encode
<?php
if (PHP_VERSION >= 50400) {
function jsonEncode(){
return call_user_func_array('json_encode', (array)func_get_args());
}
}else{
interface JsonSerializable{
@gsdevme
gsdevme / session.js
Created June 28, 2012 20:57
Session class, singleton
/*jslint nomen: true */
/*global console, define, Backbone, $, _ */
define([
'backbone'
], function () {
'use strict';
var _session = null, _instantiated = false;
@gsdevme
gsdevme / gist:2360402
Created April 11, 2012 16:35
Git help... hopefully
# create a local repo
git init
# create a remote repo
git --base init
# add a file to tracking
git add lemon.css
# add all files to tracking
@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
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 / 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();
(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');