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 / .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"
View Maybe.php
<?php declare(strict_types=1);
// In reaction to @marcoshuttle's
// Warning: none of this code has been tested or even run.
namespace Verraes\Maybe;
interface Just extends Maybe {
// We can only extract if we know it's a Just
mathiasverraes /
Created Jul 12, 2012
Recursive PHP Lint script
for file in `find .`
if [ "$EXTENSION" == "php" ] || [ "$EXTENSION" == "phtml" ]
RESULTS=`php -l $file`
mathiasverraes / MonoidalFizzBuzz.hs
Created Nov 16, 2016
Extensible Monoidal FizzBuzz in Haskell
View MonoidalFizzBuzz.hs
module MonoidalFizzBuzz where
import Data.Monoid
import Data.Maybe
-- based on @mittie
monoidalFizzbuzz = zipWith fromMaybe numbers strings
fizzes = cycle [Nothing, Nothing, Just "Fizz"]
buzzes = cycle [Nothing, Nothing, Nothing, Nothing, Just "Buzz"]
mathiasverraes / rollyourown.php
Created May 30, 2018
We don't need no DIC libs / we don't need no deps control
View rollyourown.php
// Context: I'm trying to argue that DI (and DIC) are great, and DIC libs suck.
// Happy to be proven wrong!
final class Router {
private $dependencies;
public function __construct (Dependencies $dependencies) {
$this->dependencies = $dependencies;
// You might say that this is Service Locator, but it's not. This router is toplevel,
// and toplevel must have access to dependencies. After that it can all just bubble nicely using proper DI.
mathiasverraes / TestFrameworkInATweet.php
Last active Feb 1, 2019
A unit testing framework in a tweet.
View TestFrameworkInATweet.php
function it($m,$p){echo ($p?'✔︎':'')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
git clone git://
cd php-zmq
phpize && ./configure
make && make install

Finally add the following line to your php.ini:

View water.php
<?php declare(strict_types = 1);
function volume (array $levels) {
return array_sum(
scanl('max', $levels),
scanr('max', $levels)
mathiasverraes /
Last active Jun 23, 2018
Show git branch name on command prompt. Put this in your ~/.bash_profile or whatever your OS uses, then restart your terminal and cd to a git folder. It should look something like: yourname@machine /path/to/project [my-branchname] $ UPDATE: the `` version also shows the number of entries in your git stash on the command prompt. Sc…
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
# git branch on command prompt
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\]'
PS1='\[\033[01;31m\]\u@\h \[\033[01;00m\]\w\[\033[00;33m\]$(parse_git_branch)\[\033[00m\] \$ '
mathiasverraes / .gitignore
Created May 21, 2018
gitignore a folder except the gitignore file
View .gitignore
You can’t perform that action at this time.