Skip to content

Instantly share code, notes, and snippets.

View fchaussin's full-sized avatar

François CHAUSSIN fchaussin

  • François Chaussin
  • Lyon
View GitHub Profile
@fchaussin
fchaussin / gist:449d878607f28746d8e8485e74a5dbd0
Last active February 24, 2022 10:47
Debug SQL Queries in TYPO3 Repository (Extbase)
function debug($query){
$doctrineObj = $this->objectManager
->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class)
->convertQueryToDoctrineQueryBuilder($query);
$doctrineSql = $doctrineObj->getSQL();
$params = $doctrineObj->getParameters();
$search = $replace = [];
foreach ($params as $k => $v) {
$search[] = ':' . $k;
$replace[] = '\'' . $v . '\'';
@fchaussin
fchaussin / apache_umask.md
Created March 18, 2021 08:35
set UMASK for Apache www-data

To be sure that the umask setting takes effect please use a simple test and do not use any other web application for this. It might be the case that these application change the rights independently from the umask setting of Apache.

Simple test PHP script:

<?php
if ($fp = fopen(time() . '.txt', 'w')) {
  fwrite($fp, 'This is a simple test.');
  fclose($fp);
  echo "done";

} else {

@fchaussin
fchaussin / php_packages_sury.md
Last active March 26, 2021 09:42
Failed to fetch packages.sury.org/php

$ apt update

=> error

$ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

$ sudo apt-key add /etc/apt/trusted.gpg.d/php.gpg

@fchaussin
fchaussin / tcaImageManipulation.php
Created March 30, 2021 14:23
TYPO3 ImageManipulation TCA Helper
<?php
namespace Vendor\MyExt\UserFunc;
/**
* Class TcaImageManipulation
* Image manipulation helper for TCA config
* @package Smile\MqbBase\UserFunc
*/
class TcaImageManipulation
@fchaussin
fchaussin / ssh-copy-id.md
Last active April 14, 2021 11:36
Copy SSH Key to Remote Linux Device

Generate an SSH Key

 ssh-keygen

then

ssh-copy-id -i ~/.ssh/id_rsa.pub user@host

or from windows powershell

@fchaussin
fchaussin / deploy.sh
Last active May 17, 2023 13:21
Manually deploy files, one by one with diff check
#!/bin/bash
# must be sudoer
[ `whoami` = root ] || { sudo "$0" "$@"; exit $?; }
# STD output colors // do not use for logs
RESTORE=$(echo -en '\033[0m')
GRAY=$(echo -en '\033[00;30m')
RED=$(echo -en '\033[00;91m')
GREEN=$(echo -en '\033[00;32m')
@fchaussin
fchaussin / objectToFormData.js
Created December 19, 2023 10:36
Convert JS object to FormData
function objectToFormData(object){
const formData = new FormData();
for (let [key, value] of Object.entries(object)) {
if (Array.isArray(value)) {
value.forEach((item) => {
formData.append(`${key}[]`, item);
});
} else if (typeof value === 'object') {
for (let [subKey, subValue] of Object.entries(value)) {
formData.append(`${key}[${subKey}]`, subValue)