Skip to content

Instantly share code, notes, and snippets.

View gsdevme's full-sized avatar

Gavin Staniforth gsdevme

View GitHub Profile
@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 / 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 / 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 / geo.php
Created July 24, 2012 10:52
. Storing this here incase the location goes down. http://de.60.5646.static.theplanet.com/samples/distance.php.html
/**
* This section of code was taken from here
* http://de.60.5646.static.theplanet.com/samples/distance.php.html
*/
function calcDistance($lat, $long2, $lat2, $long2, $unit='m')
{
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
@gsdevme
gsdevme / gist:3237292
Created August 2, 2012 13:58
Nice for etag & localcache idea
Etag request headers
https://github.com/documentcloud/backbone/issues/284
@gsdevme
gsdevme / Utilities.Hash.php
Created August 8, 2012 11:14
Hashing Utilities
<?php
namespace Utilities;
class Hash
{
const PASSWORD_STRENGTHENING = 50000;
/**
@gsdevme
gsdevme / gist:3911383
Created October 18, 2012 12:04
WideImage Resize/Crop
<?php
require_once __DIR__ . '/WideImage/lib/WideImage.php';
$image = WideImage::load(__DIR__ . '/product_1.jpg')
->resize(300,150,'outside')
->crop("center", "middle", 300, 150)
->saveToFile('ff.jpg');
#import the required modules
import RPi.GPIO as GPIO
import time
# set the pins numbering mode
GPIO.setmode(GPIO.BOARD)
# Select the GPIO pins used for the encoder K0-K3 data inputs
GPIO.setup(11, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
<?php
namespace Application;
use Zend\Mvc\MvcEvent;
class Module
{
public function onBootstrap(MvcEvent $e)
# This file was generated by Chef
# Do NOT modify this file by hand.
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
enabled=1
failovermethod=priority
gpgcheck=1
gpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch