Skip to content

Instantly share code, notes, and snippets.

View JeroenDeDauw's full-sized avatar
🐈
~=[,,_,,]:3

Jeroen De Dauw JeroenDeDauw

🐈
~=[,,_,,]:3
View GitHub Profile
<?php
class SharedObjectFactory {
private $container;
private $config;
public function __construct( array $config ) {
$this->container = [];
$this->config = $config;
<?php
namespace Maps;
use MediaWiki\Storage\RevisionLookup;
/**
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
@JeroenDeDauw
JeroenDeDauw / php-collections.txt
Created June 19, 2017 15:53
Talking about PHP collections
* dataProvider yield
* yield key
* yield from
* Inside out loop
* IteratorAggregate + Generator (MailTemplateFilenameTraversable)
* iterable
* iterable-functions
iterable
#! /bin/bash
# Sets up MediaWiki Vagrant in a subdirectory named mw-vagrant
# When aksed for a git user, just hit enter. Entering "anonymous" does not work.
set -ex
git clone --recursive https://gerrit.wikimedia.org/r/mediawiki/vagrant mw-vagrant
cd mw-vagrant
Big salad:
25% cous cous
15% chick peas
15% white beans
15% carrots with nuts
15% lentils
15% the thing that looks like lentils and is in between them and the chick peas
No dressing
@JeroenDeDauw
JeroenDeDauw / test_properties.py
Created December 12, 2016 17:41
Python properties
# Tested with Python 3.5
# Fails on 2.x
from unittest import TestCase, main
class Point:
def __init__(self, x, y):
self._x = x
@JeroenDeDauw
JeroenDeDauw / PythonValueObject.py
Last active December 8, 2016 15:10
Python Value Object using namedtuple
# Tested with Python 3.5
from unittest import TestCase, main
from collections import namedtuple
import math
class Point(namedtuple('Point', 'x, y')):
def get_distance_from_origin(self):
@JeroenDeDauw
JeroenDeDauw / MJAU.txt
Last active August 3, 2016 07:31
Boundaries and dependency rules
* Domain Model (Entities, value objects, aggregates) depends on "nothing" (PHP, possibly libraries such as Euro)
* Domain Services are defined as interfaces that can only depend, and always depend, on domain concepts (and the domain model)
* Repositories (a kind of Domain Service?) are defined as interfaces that can only depend, and always depend, on domain concepts (and the domain model)
* Implementations of Repositories and Domain Services can depend on whatever (ie Doctrine, Monolog)
* Use Cases can only depend on the Domain Model, Domain Service (interfaces) and Repositories (interfaces)
* Use Cases form the API to the Domain. Higher level code cannot directly access the domain / domain concepts should not occur "outside" UCs.
* Everything bound to the Domain is part of the Bounded Context, nothing else is
* If there are multiple Domains (or rather, Sub Domains), there are multiple Bounded Contexts
* There are no dependencies between Bounded Contexts
* (Applications can use one or more Bounded Contexts, w
@JeroenDeDauw
JeroenDeDauw / ValueObjectsInPhpStuckBalls.php
Created December 4, 2015 22:14
Value Objects in PHP suck balls
trait ValueObjectsInPhpStuckBalls {
public static function newInstance() {
return new self();
}
/**
* @throws \RuntimeException
*/
public function validate() {
@JeroenDeDauw
JeroenDeDauw / CurrentFormat.json
Last active December 2, 2015 19:11
QueryR item response format
data: {
"sister city": {
"type": "string",
"value": "Berlin",
"values": [
"Berlin",
"Brussels"
]
}
}