Skip to content

Instantly share code, notes, and snippets.

@edorian
edorian / TestExample.php
Created October 31, 2011 09:45
A sample test for the bowling game kata with PHPUnitStandard issues
<?php
/*
phpcs --standard=PHPUnitStandard TestExample.php
52 | ERROR | Private methods are prohibited; found rollSpare
57 | ERROR | Private methods are prohibited; found rollMany
57 | ERROR | Function's cyclomatic complexity (2) exceeds allowed maximum of
| | 1
57 | ERROR | Function's nesting level (1) exceeds allowed maximum of 0
@edorian
edorian / clean-use.php
Created February 3, 2012 08:56 — forked from lapistano/clean-use.php
Script to clean unnecessary PHP use statements
#!/usr/bin/env php
<?php
$paths = array();
if (isset($_SERVER['argv']))
{
$paths = $_SERVER['argv'];
array_shift($paths);
if (!$paths)
@edorian
edorian / git branch cleanup
Created May 7, 2012 08:48
Cleanup remote branches not merged with "development" that are stale for 4 weeks. But don't clean master
#!/bin/bash
LOG="tee -a /tmp/branch-cleanup.log"
git checkout development
git fetch
git remote prune origin
branchlist=`git branch -r --merged development | sed 's/
@edorian
edorian / git-branch-cleanup.sh
Created June 14, 2012 07:39
Delete merged and stale git branches
#!/bin/bash
if [ ! -d "$1" ]; then
echo "Usage: "$0" path/to/git/checkout"
exit 1
fi
cd $1
LOG="tee -a /tmp/branch-cleanup.log"
@edorian
edorian / gist:3621439
Created September 4, 2012 14:04
reveal default template adjustments
<style type="text/css">
@font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 700;
src: local('Lato Bold'), local('Lato-Bold'), url(fonts/lato-bold.woff) format('woff');
}
@font-face {
font-family: 'Lato';
@edorian
edorian / gist:3636420
Created September 5, 2012 13:20
assertXPath
/**
* Assert that a XPath matches on a DomNode
*
* Uses the XPath Method boolean() to see if a node test evaluates to true
* It's true if one of the follow conditions is met:
*
* - a number is true if and only if it is neither positive or negative zero nor NaN
* - a node-set is true if and only if it is non-empty
* - a string is true if and only if its length is non-zero
* - an object of a type other than the four basic types is converted to a
@edorian
edorian / gist:3654855
Created September 6, 2012 11:04
PHPUnit memory test listener
phpunit.xml.dist:
<listeners>
<listener class="MemoryTestListener" file="./MemoryTestListener.php">
</listeners>
In the same folder: MemoryTestListener.php
<?php
class MemoryTestListener implements PHPUnit_Framework_TestListener
@edorian
edorian / gist:3690351
Created September 10, 2012 11:07
PHP Segfault PHPUnit 3.7RC3, sf2 master, php master & 5.4.6
PHP:
master & 5.4.6
Configure Command => './configure' '--prefix=/opt/php-master' '--without-pear' '--with-zlib' '--with-xsl' '--enable-debug'
Repro:
------
@edorian
edorian / gist:3749905
Created September 19, 2012 14:14
PS1 - My current Term
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[31m\]$(git branch 2>/dev/null|cut -f2 -d\* -s) \[\033[01;34m\]$\[\033[00m\] '
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift
done