Skip to content

Instantly share code, notes, and snippets.

View mathiasverraes's full-sized avatar

Mathias Verraes mathiasverraes

View GitHub Profile
@mathiasverraes
mathiasverraes / zendhttp.php
Created January 19, 2015 13:15
Bug in Zend HTTP?
<?php
$request = \Zend\Http\Request::fromString(
<<<REQ
GET /?foo=bar HTTP/1.1\r\n\r\n
REQ
);
var_dump($request->getQuery()->get('foo'));
// Expected "bar", got null
class MyClass
{
/**
* Lots of comments
*/
public function importantMethodAtTheTop()
{ // braces on new lines
// lots of newlines to create structure
@mathiasverraes
mathiasverraes / max.php
Created December 9, 2014 19:40
max($list, $function) in php
<?php
// test data
class Foo {
private $a;
private $b;
function __construct($a, $b)
{
<?php
$dispatcher = new EventDispatcher;
class SendWelcomeEmail implements QueuedEventHandler {
public function when(Event $event) {
// delegate to whenUserHasRegistered, whenFoo..
}
private function whenUserHasRegistered(UserHasRegistered $event) {
<?php
require_once __DIR__ . '/../src/Verraes/Lambdalicious/load.php';
// non generic, only deals with functions with arity=2
function curry($f) {
return function($x) use($f) {
return function($y) use($f, $x) {
return $f($x, $y);
};
};
@mathiasverraes
mathiasverraes / lambdalicious.php
Created November 17, 2014 09:13
Lambdalicious blog post
<?php
require_once __DIR__ . 'path/to/src/Verraes/Lambdalicious/load.php';
assert(
isatom(@my_atom)
);
atom(@my_atom);
assert(
isatom(my_atom)
@mathiasverraes
mathiasverraes / gist:b557d4013718a905d8b7
Created August 15, 2014 09:32
The Little Schemer continuation example ported to Erlang
-module(bla).
-compile(export_all).
a_friend(_, []) -> false;
a_friend(_, _) -> true.
main() ->
multiremberco(tuna, [strawberries, tuna, swordfish], fun a_friend/2).
multiremberco(_Atom, [], Cont) ->
<?php
final class Basket implements RecordsEvents
{
private $basketCanOnlyContainFiveProducts;
private function __construct()
{
$this->basketCanOnlyContainFiveProducts = new BasketCanOnlyContainFiveProducts();
}
### Keybase proof
I hereby claim:
* I am mathiasverraes on github.
* I am mathiasverraes (https://keybase.io/mathiasverraes) on keybase.
* I have a public key whose fingerprint is 3BCD D69A 3CBA E8EE 380A BA63 C938 C231 E989 3D78
To claim this, I am signing this object: