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 / .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 http://marcosh.github.io/post/2017/06/16/maybe-in-php.html
// 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
mathiasverraes / rollyourown.php
Created May 30, 2018
We don't need no DIC libs / we don't need no deps control
View rollyourown.php
<?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
mathiasverraes / phplint.sh
Created Jul 12, 2012
Recursive PHP Lint script
View phplint.sh
#!/bin/bash
for file in `find .`
do
EXTENSION="${file##*.}"
if [ "$EXTENSION" == "php" ] || [ "$EXTENSION" == "phtml" ]
then
RESULTS=`php -l $file`
@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active Feb 1, 2019
A unit testing framework in a tweet.
View TestFrameworkInATweet.php
<?php
function it($m,$p){echo ($p?'✔︎':'')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
View zeromq.md
git clone git://github.com/mkoppanen/php-zmq.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(
zipWith(
'subtract',
zipWith(
'min',
scanl('max', $levels),
scanr('max', $levels)
@mathiasverraes
mathiasverraes / with_stashes.sh
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 `with_stashes.sh` version also shows the number of entries in your git stash on the command prompt. Sc…
View with_stashes.sh
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\]'
else
PS1='\[\033[01;31m\]\u@\h \[\033[01;00m\]\w\[\033[00;33m\]$(parse_git_branch)\[\033[00m\] \$ '
fi
@mathiasverraes
mathiasverraes / .gitignore
Created May 21, 2018
gitignore a folder except the gitignore file
View .gitignore
*
!.gitignore
@mathiasverraes
mathiasverraes / gist:b6673d1a1e010b2db0db46ac11eb80c8
Created Apr 23, 2018 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations
View gist:b6673d1a1e010b2db0db46ac11eb80c8

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

You can’t perform that action at this time.