Skip to content

Instantly share code, notes, and snippets.

View vertexvaar's full-sized avatar

Oliver Eglseder vertexvaar

View GitHub Profile
@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 / 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 / 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 / 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 / Dockerfile
Created October 15, 2018 10:33
Dockerfile wget run progress bar
RUN wget --progress=bar:force:noscroll https://...
@vertexvaar
vertexvaar / regex.md
Last active November 19, 2021 15:08
key - label - XML to XLIFF RegEx

\t\t\t<label index="(.*?)">(.*?)</label>\n \t\t\t<trans-unit id="$1">\n\t\t\t\t<source>$2</source>\n\t\t\t</trans-unit>\n

@vertexvaar
vertexvaar / git.sh
Created August 12, 2018 11:55
Git actions for merging repos together
# Move all commits in subfolder
git filter-branch -f --tree-filter 'mkdir -p $target; for node in ./*; do if [ "$node" != "./app" ];then mv $node $target; fi; done'
# Sign all commits
git filter-branch -f --commit-filter 'git commit-tree -S "$@"'
<?php
/**
* http://www.termsys.demon.co.uk/vtansi.htm#cursor
*
* Class Cursor
*/
class Cursor
{
/**
<?php
class Accessor
{
public static function getLinkedStaticPropertyIterator($class, $property): \Iterator
{
return (\Closure::bind(
function () use ($class, $property) {
foreach ($class::${$property} as $logger) {
yield $logger;
}
@vertexvaar
vertexvaar / pre-receive
Created November 21, 2017 20:34
git pre-receive hook to decline non-signed commits
#!/bin/sh
status=0
while read oldrev newrev refname
do
git verify-commit "$newrev" 2>&- >&-
if [ $? -ne 0 ]; then
echo "[GPG] Missing signature"