Skip to content

Instantly share code, notes, and snippets.

View pixelbrackets's full-sized avatar
🧑‍🎓
Looking at other things right now

Dan Kleine (geb. Dan Untenzu) pixelbrackets

🧑‍🎓
Looking at other things right now
View GitHub Profile
@einpraegsam
einpraegsam / PageModule.php
Created July 27, 2018 08:18
TYPO3: Adding a name and email to page settings for a person which is responsible for this page-branch is often wanted from different universities. In addition we want to show in the page module when and who did the last change on the current page. Example image: https://s.nimbusweb.me/attachment/1934043/8gzcifcqtdmhktr2q553/262407-2IdneYdKSIZ3K…
<?php
declare(strict_types=1);
namespace Unitue\Project\Hooks;
use TYPO3\CMS\Backend\Controller\PageLayoutController;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException;
use TYPO3\CMS\Fluid\View\StandaloneView;
use Unitue\Project\Utility\DatabaseUtility;
use Unitue\Project\Utility\ObjectUtility;
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@joseluisq
joseluisq / img.html
Last active November 10, 2020 12:59
Render an image placeholder using a simple Data URI.
<img alt="64x64" width="64" height="64" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==">
@hollodotme
hollodotme / phplint.sh
Last active December 17, 2020 08:29
PHP linting shell script - suitable for usage in PHP alpine docker containers
#!/usr/bin/env sh
OPTIND=1
EXITCODE=0
# Default parallelization
PARALLELIZE=2
# Default file name pattern
FILENAME_PATTERN='*.php'
echo "PHP linting - looking for syntax errors in PHP files."
@tastensolo
tastensolo / imageSort.sh
Last active December 30, 2020 05:20
sorts recursiv Images in folders named by EXIF-Date
#!/bin/bash
#
###############################################################################
# Photo sorting program by Mike Beach
# For usage and instructions, and to leave feedback, see
# http://mikebeach.org/?p=4729
#
# Last update: 20-January-2016 by tastensolo
###############################################################################
#
@einpraegsam
einpraegsam / MysqlXml.txt
Created October 2, 2019 07:25
MySQL: Read and write values from XML (e.g. TYPO3 FlexForm)
# Read: Show real path in sys_file_storage
select name, uid, ExtractValue(configuration, '//T3FlexForms/data/sheet[@index="sDEF"]/language/field[@index="basePath"]/value') path from sys_file_storage where uid > 0
# Write: Set a new value (in this case a detail pid) in FlexForm of a tt_news plugin
UPDATE tt_content SET pi_flexform = UpdateXML(pi_flexform, '//T3FlexForms/data/sheet[@index="s_misc"]/language/field[@index="PIDitemDisplay"]/value', CONCAT('<value index="vDEF">', 123, '</value>' )) WHERE uid=11107
@einpraegsam
einpraegsam / DummyController.php
Created August 29, 2017 09:37
Use TYPO3 cache tags in a plugin
<?php
namespace In2code\Contacts\Controller;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* Class ContactController
*/
class ContactController extends ActionController
{
@einpraegsam
einpraegsam / NotAuthorized.php
Last active May 10, 2023 21:46
Individual 403 and 404 handling in TYPO3 9 and 10. Show a 404 page but keep wrong URL. In case of a missing frontend login, redirect to login page and redirect back after login.
<?php
declare(strict_types=1);
namespace Vendor\Sitepackage\PageHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Site\Entity\Site;
@benbalter
benbalter / parse-csv.php
Created July 24, 2012 22:28
Parse CSV into Associative Array
<?php
$lines = explode( "\n", file_get_contents( 'input.csv' ) );
$headers = str_getcsv( array_shift( $lines ) );
$data = array();
foreach ( $lines as $line ) {
$row = array();
foreach ( str_getcsv( $line ) as $key => $field )
@johanmeiring
johanmeiring / gist:2894568
Created June 8, 2012 08:52
PHP str_putcsv function
<?php
/* From: http://www.php.net/manual/en/function.str-getcsv.php#88773 and http://www.php.net/manual/en/function.str-getcsv.php#91170 */
if(!function_exists('str_putcsv'))
{
function str_putcsv($input, $delimiter = ',', $enclosure = '"')
{
// Open a memory "file" for read/write...
$fp = fopen('php://temp', 'r+');
// ... write the $input array to the "file" using fputcsv()...
fputcsv($fp, $input, $delimiter, $enclosure);