Skip to content

Instantly share code, notes, and snippets.

View jasonrobertfox's full-sized avatar

Jason Fox jasonrobertfox

View GitHub Profile
@jasonrobertfox
jasonrobertfox / commit-msg
Last active August 15, 2021 10:05
This is a commit-msg hook for git that will validate your commit message to conform to the rules outlined in http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html It's a ruby adaptation of the hook outlined in http://addamhardy.com/blog/2013/06/05/good-commit-messages-and-enforcing-them-with-git-hooks/ (Thanks Addam Hardy!)
#!/bin/sh
exec < /dev/tty
./.git/hooks/validate_commit.rb $1
@jasonrobertfox
jasonrobertfox / gist:5762006
Created June 12, 2013 00:22
Determine which possible matches fit with your schedule.
$you = array("name"=>"yourName", "startDay"=> 12, "endDay"=> 15);
$possibleMatches = array(
array("name"=>"joe", "startDay"=> 14, "endDay"=> 17),
array("name"=>"jane", "startDay"=> 10, "endDay"=> 11);
)
function findTravelBuddies(????){
????
<?php
//Input Data
$name = "Jason";
$age = 28;
function getPlural($ageArgument){
if($ageArgument == 1){
return "";
} else {
return "s";
@jasonrobertfox
jasonrobertfox / new-class.sh
Created February 21, 2013 16:30
Use to make a new class using the PSR-0 location standards.
#!/bin/sh
USAGE="Usage: new-class.sh [-u] [-i] <class>"
src='src/'
unit='tests/unit/'
int='tests/integration/'
[[ "${@: -1}" =~ (.*)\/(.*$) ]]
class=${BASH_REMATCH[2]}
path=${BASH_REMATCH[1]}
@jasonrobertfox
jasonrobertfox / feature.sublime-snippet
Created February 19, 2013 17:11
Sublime Snippet: Create Gherkin Feature
<snippet>
<content><![CDATA[
#${TM_FILENAME}
Feature: ${1:Some terse yet descriptive text of what is desired}
In order to ${2:realize a named business value}
As a ${3:explicit system actor}
I want to ${4:gain some beneficial outcome which furthers the goal}
Scenario: ${5:Some determinable business situation}
${0}
@jasonrobertfox
jasonrobertfox / php-class-test.sublime-snippet
Created December 30, 2012 02:04
Sublime Snippet: PHP unit test class.
<snippet>
<content><![CDATA[
namespace ${1:namespace};
/**
* @package ${1:namespace}
*/
class ${TM_FILENAME/(.+)\..+|.*/$1/:name} extends \PHPUnit_Framework_TestCase
{
${0}
@jasonrobertfox
jasonrobertfox / php-test-case.sublime-snippet
Created December 30, 2012 01:47
Sublime Snippet: PHP unit test case.
<snippet>
<content><![CDATA[
/**
* @test
* @group ${1:group}
*/
public function ${2:validTestName}()
{
${0:\$this->markTestIncomplete('Not yet implemented');}
}
@jasonrobertfox
jasonrobertfox / pre-commit.php.sh
Created December 30, 2012 01:36
PHP Precommit Hook
#!/bin/bash
##--CONFIGURATION--##
# add to this array of things you want to check for in your testing
checks[1]="var_dump"
checks[2]="print_r"
checks[3]="die"
if git rev-parse --verify HEAD >/dev/null 2>&1
then
@jasonrobertfox
jasonrobertfox / php-top.sublime-snippet
Created December 30, 2012 01:14
Sublime Snippet: PHP basic head block.
<snippet>
<content><![CDATA[
<?php
/**
* ${1:project}
*
* @copyright Copyright (c) 2013, Jason Fox (jasonrobertfox.com)
* @license This source file is the property of Jason Fox and may not be redistributed in part or its entirty without the expressed written consent of Jason Fox.
* @author Jason Fox <jasonrobertfox@gmail.com>
*/
@jasonrobertfox
jasonrobertfox / php-class.sublime-snippet
Created December 30, 2012 01:07
Sublime Snippet: PHP Class
<snippet>
<content><![CDATA[
namespace ${1:namespace};
/**
* @package ${1:namespace}
*/
class ${TM_FILENAME/(.+)\..+|.*/$1/:name}${4: extends ${5:class}}
{
${0}