Skip to content

Instantly share code, notes, and snippets.

View joedevon's full-sized avatar

Joe Devon joedevon

View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

<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});
};
@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:
@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
@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>
@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
@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')
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
<?php
class Sg_Session_SaveHandler_Cache implements Zend_Session_SaveHandler_Interface {
protected $_cache;
/**
* Session lifetime
*
* @var int
*/
protected $_lifetime = false;
/**
@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;