Skip to content

Instantly share code, notes, and snippets.

Mathias Verraes mathiasverraes

Block or report user

Report or block mathiasverraes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mathiasverraes
mathiasverraes / BankAccount1.php
Created Mar 21, 2011
Interface Discovery with PHPUnit's Mock objects
View BankAccount1.php
<?php
class BankAccount
{
private $twitter;
public function __construct(Twitter $twitter)
{
$this->twitter = $twitter;
}
public function deposit($amount){
}
View thincontrollers1.php
<?php
/** @Entity */
class Bug
{
/** @Column(type="integer") */
private $id;
/** @Column(length=50) */
private $status;
//...
}
@mathiasverraes
mathiasverraes / private_properties1.php
Created Mar 24, 2011
Access private properties of objects of the same class
View private_properties1.php
<?php
class Foo
{
private $private;
public function __construct($value)
{
$this->private = $value;
}
public function getOther(Foo $object)
{
@mathiasverraes
mathiasverraes / listing1.php
Created May 17, 2011
Lazy Loading with Closures
View listing1.php
<?php
// client code
$customer = $customerRepository->find($id);
$orders = $customer->getOrders();
@mathiasverraes
mathiasverraes / .bashrc
Created Nov 3, 2011 — forked from thomasvm/.bashrc
Git shortcuts
View .bashrc
#! /bin/sh
alias gs="git status"
alias gc="git commit"
alias gr="git checkout"
alias ga="git add"
alias gl="git lola"
@mathiasverraes
mathiasverraes / .bashrc
Created Nov 3, 2011 — forked from thomasvm/.bashrc
Git shortcuts
View .bashrc
#! /bin/sh
alias gs="git status"
alias gc="git commit"
alias gr="git checkout"
alias ga="git add"
alias gl="git lola"
@mathiasverraes
mathiasverraes / gist:1393879
Created Nov 25, 2011
Assert that two strings are close to each other. #phpunit
View gist:1393879
<?php
protected function assertStringDistanceInPercent($minimumPercentage, $expected, $actual)
{
$percentage = 0;
similar_text($expected, $actual, $percentage);
$this->assertGreaterThanOrEqual(
$minimumPercentage,
$percentage,
"The distance between the strings should be greater than or equal to $minimumPercentage%, got $percentage%");
@mathiasverraes
mathiasverraes / deps.ini
Created Jan 21, 2012
vendors script, replaces git submodules * MOVED TO https://github.com/Credico/git-dependency-manager *
View deps.ini
; example deps.ini file
[twig]
git=http://github.com/fabpot/Twig.git
target=vendor/twig
version=v1.7.0
@mathiasverraes
mathiasverraes / keymastertest.html
Created Apr 5, 2012
angluar + keymaster + $location
View keymastertest.html
<!doctype html>
<html ng-app>
<script src="http://code.angularjs.org/angular-1.0.0rc3.min.js"></script>
<script src="https://raw.github.com/madrobby/keymaster/master/keymaster.min.js"></script>
<script>
function HelloCntl($scope, $location) {
$scope.name = 'World';
$location.path('/foo');
key('x', function() {
console.log('x key pressed');
@mathiasverraes
mathiasverraes / gist:3046310
Created Jul 4, 2012
Display git branch in command prompt
View gist:3046310
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\u@\h \[\033[01;34m\]\w\[\033[01;35m\]$(parse_git_branch)\[\033[01;34m\] \$ \[\033[00m\]'
else
PS1='\[\033[01;31m\]\u@\h \[\033[01;00m\]\w\[\033[00;33m\]$(parse_git_branch)\[\033[00m\] \$ '
You can’t perform that action at this time.