Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
jehoshua02 / render_template.php
Last active December 31, 2015 21:29
Simple function to render a php template.
<?php
/**
* Renders template with variables
*
* @params string $template Filename of php template script
* @param array $variables Associative array of variables for template
* @return string
*/
function render_template($template, array $variables)
@jehoshua02
jehoshua02 / .sublime-project (PHPUnit Build System)
Last active December 28, 2015 22:49
Sublime project build system for PHPUnit.
{
"folders":
[
{
"path": "."
}
],
"build_systems":
[
{
@jehoshua02
jehoshua02 / coverage_check.php
Created November 11, 2013 08:18
The PHP coverage check script I use with Travis-CI
<?php
$expected = 100;
$inputFile = __DIR__ . '/coverage/clover.xml';
if (!file_exists($inputFile)) {
echo "No coverage reports found!\n";
exit(1);
}
@jehoshua02
jehoshua02 / .gitconfig_alias_pr
Last active December 27, 2015 19:49
Git alias to open pull request on Github
[alias]
# returns url for remote
url = ls-remote --get-url
# returns http url for github
ghurl = !git url | cut -d '@' -f 2 | sed 's/:/\\//' | sed 's/^/http:\\/\\//' | cut -d\\. -f 1 -f 2
# returns current branch
which = rev-parse --abbrev-ref HEAD

My 3 Rules of TDD (Experimental)

Here is my experimental version of the 3 rules of TDD:

  1. You are not allowed to write any production code unless it is to make a failing unit test pass. (No modification here)
  2. You are not allowed to write any more of a unit test than is sufficient to sufficiently test a single method. (Instead of just enough to get a failure)
  3. You are not allowed to write any more production code than is sufficient to pass all tests for the one method. (To match the new Rule #2)

Reasons for Changes

@jehoshua02
jehoshua02 / .bash_pull_request
Created October 25, 2013 16:54
Simple bash function to submit pull request
alias github_url="git ls-remote --get-url | cut -d '@' -f 2 | sed 's/:/\//' | sed 's/^/http:\/\//' | cut -d\. -f 1 -f 2"
alias current_branch="git rev-parse --abbrev-ref HEAD"
function pull_request() {
git push origin $(current_branch)
open $(github_url)/compare/$1...$(current_branch)
@jehoshua02
jehoshua02 / Preferences.sublime-settings
Created October 18, 2013 19:20
My sublime configs
{
"color_scheme": "Packages/User/Github.tmTheme",
"ignored_packages":
[
"Vintage"
],
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"ensure_newline_at_eof_on_save": false,
"draw_white_space": "all",
@jehoshua02
jehoshua02 / _composer_phpunit.md
Last active December 25, 2015 20:49
Barebones Composer and PHPUnit configuration.

It's really easy to set up PHPUnit with Composer. Just drop composer.json and phpunit.xml.dist in your project root. Then you need to tell Composer to install:

composer install

Then you can run tests:

vendor/bin/phpunit
@jehoshua02
jehoshua02 / README.md
Created October 16, 2013 08:16
Hastle free PHP debugging with !

In the xdebug docs, I found a list of debugging clients!

I chose a standalone called MacGDBp.

I also widdled the xdebug configs down to the bare minimum for hastle free debugging:

zend_extension=/usr/lib/php5/20090626/xdebug.so

xdebug.remote_enable = 1 
@jehoshua02
jehoshua02 / Hookable.php
Last active December 23, 2015 20:49
Hooks ... maybe good for caching or logging errors?
<?php
/*
* @todo I wish there was a way to hook before and after a method without explicitly calling the hooks in the method.
* In other words, the method would be ignorant of any hooks. This would allow you to hook into any existing methods
* without even touching those methods. There's only two ways I can think of doing this: extending PHP to provide the
* hookable interface on every object, or to put the object in a hookable container.
*/