Skip to content

Instantly share code, notes, and snippets.

View wazum's full-sized avatar
😼
I may be slow to respond.

Wolfgang Klinger wazum

😼
I may be slow to respond.
View GitHub Profile
@wazum
wazum / EventLinkViewHelper.php
Created June 9, 2020 07:43
TYPO3 news ViewHelper to add hrDate setting
<?php
namespace Vendor\MyExtension\ViewHelpers;
use GeorgRinger\News\Domain\Model\News;
use GeorgRinger\News\ViewHelpers\LinkViewHelper;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class EventLinkViewHelper extends LinkViewHelper
@wazum
wazum / cropVariantsInUserFunction.php
Created March 4, 2020 15:03
Create an image with a specific cropping variant in a TYPO3 user function or similar
<?php
$contentObjectRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
$filesContent = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\FilesContentObject::class,
$contentObjectRenderer);
$filesConfiguration = [
'references' => '50', // this is a UID from sys_file_reference
'renderObj' => 'IMAGE',
'renderObj.' => [
'file' => '50', // this is the same UID as above
@wazum
wazum / EventLinkViewHelper.php
Last active February 10, 2020 11:52
TYPO3 9.5+ routing for news (TypoScript hrDate = 0) and eventnews (TypoScript hrDate = 1)
class EventLinkViewHelper extends LinkViewHelper
{
/**
* Render link to news item or internal/external pages.
*
* Adds the hrDate settings to create links with a date.
*
* @return string link
<?php
declare(strict_types=1);
namespace Vendor\Extension\Database\Query;
class QueryBuilder extends \TYPO3\CMS\Core\Database\Query\QueryBuilder
{
/**
* Specifies an ordering for the query results.
* Replaces any previously specified orderings, if any.
<?php
declare(strict_types=1);
namespace Vendor\MyExtenstion\Test\Functional\Service;
use …
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class ConcreteSomethingImportServiceTest extends FunctionalTestCase
{
<?php
declare(strict_types=1);
namespace Vendor\MyExtension\Test\Unit\Service;
use Vendor\MyExtension\Service\AbstractSomethingService;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
class AbstractSomethingServiceTest extends UnitTestCase
{
@wazum
wazum / aspect_ratio.php
Last active October 26, 2023 13:41
PHP Calculate aspect ratio from width and height
<?php
function getAspectRatio(int $width, int $height)
{
// search for greatest common divisor
$greatestCommonDivisor = static function($width, $height) use (&$greatestCommonDivisor) {
return ($width % $height) ? $greatestCommonDivisor($height, $width % $height) : $height;
};
$divisor = $greatestCommonDivisor($width, $height);
rofi -help
rofi usage:
rofi [-options ...]
Command line only options:
-no-config Do not load configuration, use default values.
-v,-version Print the version number and exit.
-dmenu Start in dmenu mode.
-display [string] X server to contact.
${DISPLAY}
@wazum
wazum / StaticPaddedRangeMapper.php
Created January 28, 2019 13:40
TYPO3 CMS 9.5 StaticPaddedRangeMapper Routing Aspect
<?php
declare(strict_types=1);
namespace Vendor\Extension\Routing\Aspect;
use TYPO3\CMS\Core\Routing\Aspect\StaticRangeMapper;
/**
* Class StaticPaddedRangeMapper
* @package Vendor\Extension\Routing\Aspect
@wazum
wazum / checkpoint.sh
Last active November 25, 2017 17:48 — forked from bubenkoff/checkpoint.sh
Endpoint Security VPN FULL start/stop script for Mac OS X
#!/bin/bash
#
# The reason of creating this script is that Endpoint Security VPN installs it's own application firewall kext cpfw.kext
# which prevents for example PPTP connections from this computer, which is not appropriate if you need subj connection just
# from time to time
# Usage: checkpoint.sh load|unload
# You will need sudo power, of course
#
if [ $1 == "unload" ]