Skip to content

Instantly share code, notes, and snippets.

View vertexvaar's full-sized avatar

Oliver Eglseder vertexvaar

View GitHub Profile
@vertexvaar
vertexvaar / es-cqrs-obstacles.md
Last active January 7, 2019 14:39
Event Sourcing / CQRS Obstacle Dodging

YAGNI! (Think twice before choosing ES and at least 10 times before choosing CQRS - Anyone with experience ever)

Uniqueness:

  • Single value table on command side with index
  • Implementable as service or sth. like that

Crossing ES borders:

  • Use ProcessManager for creating ES-external entities

Referencing Projections in ORM

@vertexvaar
vertexvaar / ldap_test.php
Created December 10, 2018 13:19
LDAP connection test script
<?php
$host = '';
$port = '636';
$ldaps = true;
$version = 3;
$username = '';
$password = '';
if (strpos($host, 'ldaps:') === 0) {
@vertexvaar
vertexvaar / ControllerConverterCollection.php
Created December 13, 2018 14:22
Flow DateTime converter with auto zero hour
<?php
trait ControllerConverterCollection {
protected function setDateTimeConverterFormatForArgument(string $argumentName, string $property, string $format)
{
if ($this->request->hasArgument($argumentName) && $this->arguments->hasArgument($argumentName)) {
if (strrpos($format, 'H') === false) {
/** @var array $argument */
$argument = $this->request->getArgument($argumentName);
$dateTime = \DateTime::createFromFormat($format, $argument[$property]);
$dateTime->setTime(0, 0, 0);
@vertexvaar
vertexvaar / iterator_iteration.php
Last active January 4, 2019 11:17
You might not know this about PHP!
<?php
/* Classes implementing iterators can not be used for nested iterating without ugly side effects.
* Iterations over arrays create copies of the arrays with seperate array pointers.
* Iterations over Iterater will only call the object which does not know in which loop it get's called and can not create a second or third pointer on the array for nested iterating.
* To dodge this we must use the array. If the iterator implements a toArray method we're fine. If not, we still can use iterator_to_array().
*/
// Expected
@vertexvaar
vertexvaar / flow-features.md
Last active January 17, 2019 13:27
Neos Flow Framework Features you probably didn't know

Features

./flow package:create (The hidden feature)

Okay, let's be honest. You know that package:create command. But did you know, that if your composer.json contains a repository with a local path Flow will create the package in that path and run a composer require .?

The composer.json has to look like this:

@vertexvaar
vertexvaar / script.sh
Created March 21, 2019 13:25
rsync example command to sync a folder with a progress bar for the complete transaction
rsync --exclude '*.zip' \
--exclude '*.ZIP' \
--exclude=_processed_ \
--info=progress2 \
--max-size=2M \
-azO \
-e ssh \
$(SYNCSERVER):$(SYNCFOLDER)/fileadmin/ Web/fileadmin/
@vertexvaar
vertexvaar / mysqldump-short.sh
Last active July 28, 2020 13:01
MySQL Dump with UTF8 and better performance on import
mysqldump --add-drop-database --create-options --extended-insert --no-autocommit --add-locks --quick --default-character-set=utf8 --result-file=database.sql -h localhost -u root -p root database
@vertexvaar
vertexvaar / roman_numerals.php
Created April 27, 2019 17:45
Convert decimal integer to roman numerals
<?php
$input = 3486;
$expected = '';
function whatever(int $input)
{
$map = [
1 => 'I',
5 => 'V',
@vertexvaar
vertexvaar / getIp.sh
Last active November 26, 2019 08:10
Get primary IP address
#!/bin/bash
echo "The hostname way"
echo $(hostname --all-ip-addresses | cut -d' ' -f1)
echo "more complicated but stable"
echo $(ifconfig $(/sbin/ip route | grep -v tun | awk '/default/ { print $5 }') | awk -F ' *|:' '/inet /{print $3}')
@vertexvaar
vertexvaar / notkay.txt
Created September 24, 2019 20:24
The myth of loose coupling with PSR-15 (WIP)
Ever thought about changing your `ServerRequestFactory`?
Did you try to add a `Middleware` but you can't because you can not just implement the interface and have it magically called before *that* other `Middleware`?