Skip to content

Instantly share code, notes, and snippets.

View mathiasverraes's full-sized avatar

Mathias Verraes mathiasverraes

View GitHub Profile
@mathiasverraes
mathiasverraes / fseu.php
Created October 7, 2022 09:36
Output of my live coding impro at Full Stack Europe 2022
<?php declare(strict_types=1);
// @mathiasverraes
// parser is a function that takes some input and returns (either (structured value AND remainder) OR error)
// parser is a function that takes some input and returns a Result
$a = function ($input) {
$parsed = substr($input, 0, 1);
$remainder = substr($input, 1);
if ($parsed === 'a') return succeed($parsed, $remainder); else return fail("expected a");
};

My kid 11yo has a blood phobia. I asked Twitter for suggestions for action/adventure/scifi/fantasy/comedy movies that are suitable for a 9 and 11 yo who like Star Wars and Back to the Future.

Below are the movies people have suggested. They often did so from memory, and I haven't validated if they are indeed suitable. However, I learned about this site where you can lookup if a moview has blood or other phobia-inducing content: https://www.doesthedogdie.com/

Has no blood

@mathiasverraes
mathiasverraes / ExcelTest.php
Created September 26, 2020 21:43
Parsica excel example
<?php declare(strict_types=1);
/*
* This file is part of the Parsica library.
*
* Copyright (c) 2020 Mathias Verraes <mathias@verraes.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@mathiasverraes
mathiasverraes / maps_vs_models.md
Created October 14, 2019 20:57
maps vs models

https://twitter.com/janellekz/status/1183805720225107976?s=20

Well I know Simon's ideas on the matter, that's why I was asking for yours. I haven't given it enough thought to have strong opinions but here's a quick attempt:

Similar: Models and maps both consists of abstractions. The abstractions are chosen, for a purpose, in a context.

Different: Models are conceptual. Models are not just tools for understanding, they are understanding. I can draw or code or somehow express a model, but it's only a representation of an underlying model, not the model itself.

Landscapes and maps are physical. The symbols on the map are linked to things in the landscape. You don't visualize a map, the visualisation is the map.

@mathiasverraes
mathiasverraes / rollyourown.php
Created May 30, 2018 14:17
We don't need no DIC libs / we don't need no deps control
<?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 / .gitignore
Created May 21, 2018 13:23
gitignore a folder except the gitignore file
*
!.gitignore
@mathiasverraes
mathiasverraes / gist:b6673d1a1e010b2db0db46ac11eb80c8
Created April 23, 2018 10:21 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

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:

@mathiasverraes
mathiasverraes / fib.php
Created November 14, 2017 09:46
Supposedly Lazy Fibonacci
<?php
foreach (fib() as $x) echo "$x\n";
function fib () {
yield 0; yield 1;
$f = fib(); $g = fib();
$g->next();
while (true) {
yield $f->current() + $g->current();
$f->next(); $g->next();
<?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 / water.php
Last active July 19, 2018 05:23
Water Kata
<?php declare(strict_types = 1);
function volume (array $levels) {
return array_sum(
zipWith(
'subtract',
zipWith(
'min',
scanl('max', $levels),
scanr('max', $levels)