Skip to content

Instantly share code, notes, and snippets.

@naitsirch
naitsirch / AjaxAuthenticationListener.php
Last active Aug 29, 2015 — forked from xanf/AjaxAuthenticationListener.php
How to register an Symfony event handler to prevent JSON/AJAX requests to be redirected
View AjaxAuthenticationListener.php
<?php
namespace Acme\Bundle\MyBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
class AjaxAuthenticationListener
{
@naitsirch
naitsirch / Handle fatal errors with Symfony.php
Created Jun 18, 2014
Send HTTP 500 status code on fatal errors with Symfony.
View Handle fatal errors with Symfony.php
<?php
/**
* This could be the Bundle class of your main bundle.
*/
namespace Acme\DemoBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AcmeDemoBundle extends Bundle
View buchhaltung.public.pgp
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG C# v1.6.1.0
mQENBFapJesBCACG4fePa1EoifVbdl++YV8r7pp3phIXSRG2/k4Cwl83mJ0zQmkp
CnqcRMTlGJEEx2YQ22BpfPu4orl0YZUvaPNv5Pwto6IjJxtWOG6rOknMEQVSB8LW
pww3dlraphOAqh6K6K9BWpbAjYrNMm7qKNBrw0otr3uO4vSoxFFdf8DFbzD6QNef
qf4LwUmAY+EX/x/UEci/Oz46KLEvQF5dyeXiO0duL7ciw5Q4PpaTfC1Z/kQj+fuc
B3uOt+7F3Cels+REdag2Wh2paWUgRRwKBuez6UQ1QD8HUMN9Lu1iLpaDVs1IRjO3
RYhbkl3mEfZYCXSOoL8p7e6FRxw+Kc82KXlxABEBAAG0FGJ1Y2hoYWx0dW5nQGVj
Z3BiLmRliQEcBBABAgAGBQJWqSXrAAoJEJesuMl7eFyHr0wH/2FwICc087uIGj7f
@naitsirch
naitsirch / pre-commit
Last active Mar 19, 2019
Check if Git username is defined locally
View pre-commit
#!/bin/bash
# ## Description
# This pre-commit git hook makes sure that a local username is defined if there is any remote repository on github.
# This is helpful if you are working with multiple remote hosts and use different usernames. If you forget to configure
# the local username you may end up sending a wrong username to your github remote.
#
# ## Usage
# This is script is only useful if you make it available as a hook template. To achieve this, follow these steps:
#
@naitsirch
naitsirch / Symmetric Encryption and Decryption of large Files with OpenSSL.md
Last active Apr 12, 2019
Symmetric Encryption and Decryption of large Files with OpenSSL
View Symmetric Encryption and Decryption of large Files with OpenSSL.md

PHP lacks a build-in function to encrypt and decrypt large files. openssl_encrypt can be used to encrypt strings, but loading a huge file into memory is a bad idea.

So we have to write a userland function doing that. This example uses the symmetric AES-128-CBC algorithm to encrypt smaller chunks of a large file and writes them into another file.

Encrypt Files

@naitsirch
naitsirch / datensicherung.bat
Created Sep 8, 2019
Papas Datensicherungs-Script
View datensicherung.bat
@echo off
echo.
echo Hallo,
echo die Datensicherung wird gestartet. Datensicherung wird unter E: gesichert.
echo.
robocopy "C:\Users\Heinrich\Desktop" "E:\Datensicherung\Desktop" /MIR /NP
robocopy "C:\Firma" "E:\Datensicherung\Firma" /MIR /NP
robocopy "C:\Privat" "E:\Datensicherung\Privat" /MIR /NP
@naitsirch
naitsirch / datensicherung.bat
Created Sep 8, 2019
Papas Datensicherungs-Script
View datensicherung.bat
@echo off
echo.
echo Hallo,
echo die Datensicherung wird gestartet. Datensicherung wird unter E: gesichert.
echo.
robocopy "C:\Users\Heinrich\Desktop" "E:\Datensicherung\Desktop" /MIR /NP
robocopy "C:\Firma" "E:\Datensicherung\Firma" /MIR /NP
robocopy "C:\Privat" "E:\Datensicherung\Privat" /MIR /NP
@naitsirch
naitsirch / README.md
Created Sep 24, 2019
FastCGI und PHP-FPM mit Apache 2.4 und PHP 7.x unter Debian nutzen
View README.md

Apache mit FastCGI und PHP-FPM

Bei Debian sollte '''nicht''' das fastcgi sondern das proxy_fcgi Modul verwendet werden. Dafür wird die Konfiguration standardmäßig bereitgestellt.

Zunächst müssen die passenden Pakete installiert werden:

sudo apt install php-fpm

Die Konfigurationsdateien finden sich unter