Skip to content

Instantly share code, notes, and snippets.

View GRMule's full-sized avatar

Chris Baker GRMule

View GitHub Profile
<?php
require_once('../vendor/autoload.php'); // composer autoload
class Foo {
public $someProperty = 'val1';
}
class Bar {
public function __construct($valueFromFoo){
@GRMule
GRMule / gist:d2f9c42f2a9b39080ee5
Created May 12, 2015 21:40
Sample of a basic PDO wrapper class
<?php
/**
* Sample of a basic wrapper class for PDO.
*
* This is provided as a demonstration only and no warranty is intended
* about the completeness or soundness of this snippet.
*
* Use:
*
class MathIsFun {
private $someInterface = null;
public function __construct(iSomeInterface $dependency) {
$this->someInterface = $dependency;
}
public function add($number=0) {
return $number + $this->someInterface->getNumber();
}
}
@GRMule
GRMule / gist:7775384
Created December 3, 2013 19:00
A partially working effort to parse and normalize address data
function parse_address($address){
$dir=array(
'N'=>'N','S'=>'S','E'=>'E','W'=>'W','NW'=>'NW','SW'=>'SW','NE'=>'NE','SE'=>'SE',
'North'=>'N','South'=>'S','East'=>'E','West'=>'W','Northwest'=>'NW','Southwest'=>'SW','Northeast'=>'NE','Southeast'=>'SE'
);
$type=array(
'ave'=>'Ave','blvd'=>'Blvd','st'=>'St','wy'=>'Wy','cir'=>'Cir','dr'=>'Dr','ln'=>'Ln','Pl'=>'Pl','Rd'=>'Rd',
'Bvd'=>'Blvd',
'Avenue'=>'Ave','Boulevard'=>'Blvd','Street'=>'St','Way'=>'Wy','Circle'=>'Cir','Drive'=>'Dr','Lane'=>'Ln','Place'=>'Pl','Road'=>'Rd'
@GRMule
GRMule / blackCoffee.js
Created September 12, 2012 03:26
blackCoffee, the newest javascript framework
/*
blackCoffee is the ultra-light, ultra-fast alternative to jQuery. Our slogan is:
--> Write the same amount, do an equal amount as you otherwise may have done
It isn't very catchy -- now taking suggestions for a better slogan!
*/
var blackCoffee = function (selector) {
if (typeof selector != 'string')
return null;
if (selector.match('#')){
@GRMule
GRMule / gist:3315289
Created August 10, 2012 16:11
call_user_func_array doesn't always pass fake references, but when it does, it drinks Dos Equis beer.
<?php
ini_set('display_errors', '1');
error_reporting(E_ALL | E_STRICT);
class testRef {
function test (&$parm1, &$parm2) {
echo '<br>In testRef::test(), param1: '.$parm1;
echo '<br>In testRef::test(), param2: '.$parm2;
}
}
@GRMule
GRMule / gist:3306716
Created August 9, 2012 18:15
Quickie paypal implementation (untested)
function chargeCreditCard($detail) {
$API_USERNAME = '-USERNAME-';
$API_PASSWORD = '-PASSWORD';
$API_CERTIFICATE = '-SSL-CERT-';
$API_SIGNATURE = '';
$API_ENDPOINT = 'https://api.paypal.com/nvp';
$PAYPAL_URL = 'https://www.paypal.com/webscr&cmd=_express-checkout&token=';
$VERSION = '51.0';
$return = array(