Skip to content

Instantly share code, notes, and snippets.

View christophlehmann's full-sized avatar

Christoph Lehmann christophlehmann

View GitHub Profile
@christophlehmann
christophlehmann / general-log.sh
Created October 8, 2023 21:11
Follow MySQLs general log
#!/bin/bash
trap 'mysql -e "SET GLOBAL general_log=0"; exit' SIGINT SIGQUIT
log_file="$(mysql -N -e 'SHOW VARIABLES WHERE variable_name="general_log_file"' | awk '{print $2}')"
test -f $log_file && rm $log_file
mysql -e "SET GLOBAL general_log=1"
tail -f $log_file
@christophlehmann
christophlehmann / SlugUtility.php
Created September 25, 2023 13:41
TYPO3: Slug generation for Extbase Objects
<?php
namespace My\Site\Utility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory;
use TYPO3\CMS\Core\DataHandling\SlugHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface;
@christophlehmann
christophlehmann / Shard.php
Last active December 26, 2022 20:22
TYPO3 Solr: Search across multiple languages (language per core = Do not loose features like stemming)
<?php declare(strict_types=1);
namespace My\Site\Query\Modifier;
use ApacheSolrForTypo3\Solr\ConnectionManager;
use ApacheSolrForTypo3\Solr\Domain\Search\Query\QueryBuilder;
use ApacheSolrForTypo3\Solr\Domain\Search\Query\Query;
use ApacheSolrForTypo3\Solr\Query\Modifier\Modifier;
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
use ApacheSolrForTypo3\Solr\Util;
use TYPO3\CMS\Core\Utility\GeneralUtility;
<?php
namespace Lemming\SiteExtension\Routing;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Routing\RouteCollection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Routing\ExtbasePluginEnhancer;
@christophlehmann
christophlehmann / check_k8s_certificate_expiration.sh
Created December 30, 2021 14:16
Kubernetes: Check TLS certificate expiration
#!/bin/bash
# 2 weeks
warn_in_seconds=1209600
for namespace in $(kubectl get ns | grep -v ^NAME | awk '{print $1}')
do
for secret in $(kubectl -n $namespace get secrets | grep kubernetes.io/tls | awk '{print $1}')
do
cert=$(kubectl -n $namespace get secret $secret -o json | jq -r '.data["tls.crt"]')
@christophlehmann
christophlehmann / Lemming\Extension\Command\CacheHashCommandController.php
Last active December 12, 2018 12:05
Repair wrong chashes in tx_realurl_urldata table
<?php
namespace Lemming\Extension\Command;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
class CacheHashCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController
{
const TABLE = 'tx_realurl_urldata';
@christophlehmann
christophlehmann / fail2ban-filter-sql-scanner.conf
Created November 8, 2018 07:33
Apache log fail2ban sql injection scanner
[Definition]
failregex = ^<HOST> .*UNION%%20SELECT%%20CHAR.*HTTP
^<HOST> .*select\*from.*HTTP
^<HOST> .*select%%20name_const.*HTTP
# Dev notes
#
# % must be escaped with '%'
@christophlehmann
christophlehmann / prometheus-operator-kubernetes.yaml
Last active April 29, 2024 11:44
Example: Monitoring external server with Prometheus Operator
# First install prometheus-operator:
#
# helm install coreos/prometheus-operator --name prometheus-operator
#
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: node-exporter
# Namespace of prometheus operator
@christophlehmann
christophlehmann / SimpleEmailLinkFactory.php
Last active March 4, 2017 10:39
email2powermail old behaviour for TYPO3 7.6
<?php
use In2code\Email2powermail\Domain\Factory\EmailLinkFactory;
use In2code\Email2powermail\Domain\Model\Email;
use In2code\Email2powermail\Domain\Model\EmailLink;
use In2code\Email2powermail\Domain\Repository\EmailRepository;
use In2code\Email2powermail\Utility\ConfigurationUtility;
use In2code\Email2powermail\Utility\ObjectUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
@christophlehmann
christophlehmann / typo3-news-sitemap.ts
Last active December 8, 2016 19:46
TYPO3 TypoScript sitemap for news extension
# Sitemap for news
[globalVar = TSFE:type = 1481221329]
config {
disableAllHeaderCode = 1
admPanel = 0
metaCharset = utf-8
additionalHeaders = Content-Type:text/xml;charset=utf-8
disablePrefixComment = 1
}