Skip to content

Instantly share code, notes, and snippets.

View joedevon's full-sized avatar

Joe Devon joedevon

View GitHub Profile
@jwage
jwage / SplClassLoader.php
Last active April 9, 2024 21:04
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@raphaelstolt
raphaelstolt / redis-glue-test.php
Created May 15, 2010 04:45
Redis installation test script
<?php
define('TEST_KEY', 'are_we_glued');
$redis = new Redis();
try {
$redis->connect('localhost', 6379);
$redis->set(TEST_KEY, 'yes');
$glueStatus = $redis->get(TEST_KEY);
if ($glueStatus) {
$testKey = TEST_KEY;
echo "Glued with the Redis key value store:" . PHP_EOL;
<?php
class Sg_Session_SaveHandler_Cache implements Zend_Session_SaveHandler_Interface {
protected $_cache;
/**
* Session lifetime
*
* @var int
*/
protected $_lifetime = false;
/**
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@johnkary
johnkary / gist:634490
Created October 19, 2010 16:20
Using PHPUnit 3.5 MockBuilder to create a mock concrete object of an abstract class
<?php
//Create mock BaseCredential called 'MockAdminCredential' whose 'calculate'
//function will always return true. All other methods will return NULL
//as per the default behavior of a stub.
$this->mockAdminCredential = $this->getMockBuilder('BaseCredential')
->setMockClassName('MockAdminCredential')
->setMethods(array('calculate'))
->getMock()
->expects($this->any())
->method('calculate')
@johnkary
johnkary / gist:635035
Created October 19, 2010 20:27
What is best practice for building a mock used across several tests?
<?php
/**
* Having trouble building the same mock in my setUp() method.
* What is best practice for building a mock used across several tests?
*
* Error:
* 1) SystemUnderTestTest::testSecondTest
* PHPUnit_Framework_Exception: Class "MockStaffCredential" already exists.
*/
class SystemUnderTest
@getify
getify / gist:713779
Created November 24, 2010 15:09
loading google analytics using LABjs
<!DOCTYPE html>
<html>
<head>
<title>LABjs Demo</title>
</head>
<body>
<!-- some stuff -->
<script src="/js/LAB.js"></script>
@westonruter
westonruter / filterable.php
Created March 11, 2011 22:42
Adding filtering to any class simply by having it extend the Filterable class.
<?php
// Builds off of Aspect-Oriented Design demo by Garrett Woodworth:
// <http://phpadvent.org/2010/aspect-oriented-design-by-garrett-woodworth>
class Filters {
protected static $_filters = array();
/**
* Register a new filter; note there could be an array index also provided
* to indicate where in the list order that a callback filter should be applied
@westonruter
westonruter / cdup.sh
Created August 5, 2011 21:17
Bash shortcut function to cd you to an ancestor directory, named as first argument. Stop having to cd ../../../..
#!/bin/bash
# Usage: cdup [DIRNAME]
# Bash shortcut function to cd you to ancestor directory named as first argument.
# If DIRNAME is not supplied, then .. is used.
# Stop having to cd ../../../..
# Use `cd -` to undo, to restore old working directory.
# Use aliases for common directories, like: alias docroot="cdup docroot".
# Add function to your ~/.profile
#
# Example:
<script src="LAB.js"></script>
<script>
// put whatever here, for your page's other scripts that you load with <script> tags.
$LAB.script("my_script1.js").script("my_script2.js").wait().script("my_script3.js");
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};