Skip to content

Instantly share code, notes, and snippets.

View kitzberger's full-sized avatar

Philipp Kitzberger kitzberger

View GitHub Profile
@kitzberger
kitzberger / curl.sh
Created March 12, 2025 10:01
Cheatsheet for curl
# Print only response header
curl -sS -D - -o /dev/null 'https://www.google.de'
@kitzberger
kitzberger / curl-and-jq-example.sh
Last active April 9, 2025 10:57
jq cheatsheet
# This pretty-prints the JSON response:
curl -s "https://api.example.com/data" | jq '.'
# Useful flags
# -c compact
# To get all items:
curl -s "https://api.example.com/data" | jq '.items[]'
# To count all items:
curl -s "https://api.example.com/data" | jq '.items[] | length'
@kitzberger
kitzberger / composer-update.sh
Last active January 20, 2025 13:51
Update version constrains in composer.json before running `composer update`
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RESET='\033[0m'
packages=$(jq -r '.require | with_entries(select(.key | test("^typo3/") | not)) | keys[]' composer.json)
for package in $packages; do

export only inserts

mysqldump <db> <table> --skip-triggers --compact --no-create-info 

# with column names in INSERT statement
mysqldump <db> <table> --skip-triggers --compact --no-create-info --complete-insert

export only structure

@kitzberger
kitzberger / TYPO3-Redirects.md
Created June 13, 2024 07:00
Debugging TYPO3 Redirects
$GLOBALS['TYPO3_CONF_VARS']['LOG']['TYPO3']['CMS']['Redirects'] => [
   'Service' => [
       'RedirectService' => [
           'writerConfiguration' => [
               \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
                   \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
                       'logFileInfix' => 'core-redirect-service'
                   ],
],
@kitzberger
kitzberger / setup.typoscript
Last active May 29, 2024 13:04
TYPO3: clever HMENU browse next/prev
# This menu is considered to be 'clever' due to the fact that it's sliding accross the entire page tree:
#
# * Previous link: if there's no previous sibling page, we're linking to the parent page instead
# * Next link:
# * if there's no child page, we're linking to the next sibling page
# * if that's not available, we're linking to the next sibling page of the parent page
# * if that's not available, we're linking to the next sibling page of the grandparent page
temp.browseMenuItem = HMENU
temp.browseMenuItem.special = browse
@kitzberger
kitzberger / sed examples.md
Created March 14, 2024 08:02
Useful sed commands

Duplicate a line and modify it

sed '/pattern/{p;s/pattern/replacement/}' input_file

Explanation:

  • /pattern/: This specifies the pattern that identifies the line you want to duplicate and modify.
  • {p;s/pattern/replacement/}: This is a group of commands enclosed within {}.
@kitzberger
kitzberger / Form.yaml
Created March 2, 2024 08:41
TYPO3 EXT:form field with label override per finisher
renderables:
-
type: Page
identifier: page
label: Form
renderables:
-
defaultValue: ''
type: Text
identifier: name
@kitzberger
kitzberger / MyClass.php
Created August 1, 2023 07:45
TYPO3 Timetracker
<?php
$tt = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TimeTracker\TimeTracker::class);
$tt->start();
// Expensive operation here
$tt->finish();
// Print the runtime between start and finish in milliseconds.
@kitzberger
kitzberger / PageModuleEventListener.php
Last active October 11, 2024 10:53
TYPO3 PageModule Enhancements
<?php
/*
TYPO3 12+
Registration in Services.yaml
See https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Events/Events/Backend/ModifyPageLayoutContentEvent.html
*/
declare(strict_types=1);