Skip to content

Instantly share code, notes, and snippets.

View vertexvaar's full-sized avatar

Oliver Eglseder vertexvaar

View GitHub Profile
@vertexvaar
vertexvaar / sortArrayCustom.php
Last active April 17, 2020 15:24
Sort an multi dimensional array by unique array value in custom order
<?php
$functions = [
'usort (from stackoverflow)' => function (array $input, array $order): array {
usort(
$input,
function ($a, $b) use ($order) {
$pos_a = array_search($a['id'], $order);
$pos_b = array_search($b['id'], $order);
return $pos_a - $pos_b;
@vertexvaar
vertexvaar / SomeCommand.php
Last active October 21, 2022 15:55
Symfony Console mulitple subprocess status bar with overall progress and message
<?php
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@vertexvaar
vertexvaar / query.sql
Created November 29, 2019 09:52
SQL query select News Plugin with "List News" action
SELECT *
FROM tt_content
WHERE `CType` = 'list'
AND `list_type` = 'news_pi1'
AND ExtractValue(`pi_flexform`,
'/T3FlexForms/data/sheet[@index="sDEF"]/language[@index="lDEF"]/field[@index="switchableControllerActions"]/value[@index="vDEF"]/text()')
IN ("News->list;News->detail", "News-&gt;list;News-&gt;detail");
@vertexvaar
vertexvaar / .env
Last active November 26, 2019 08:22
Create host entry in makefile if it does not exist for linux and mac
HOST=local.project.com
@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`?
@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 / 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 / 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 / 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 / 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: