Skip to content

Instantly share code, notes, and snippets.

View rordi's full-sized avatar
🎓

Dietrich Rordorf rordi

🎓
View GitHub Profile
@rordi
rordi / phpdoc.md
Last active March 10, 2023 15:22
Generate PhpDoc Documentation with Docker

Easily create a PhpDoc documentation with this Docker container

Use following command from withint the root directory of your PHP project to create the PhpDocs in the ./docs subfolder of the project root. You may want to include only a ./src (Symfony) or ./app (Silex) subfolders in the analysis (do not run the documentator on the ./vendors folder):

docker run --rm -v $(pwd):/app instrumentisto/phpdoc -d /app -t ./docs

@rordi
rordi / cors.md
Last active March 21, 2022 14:04
Simplest, configurable CORS implementation for Symfony through listeners

Simplest, configurable CORS implementation for Symfony through listeners

CorsListener.php event listener for pre-flight OPTIONS requests

<?php
/**
 * CorsListener.php
 *
 * @author Dietrich Rordorf
0xAd9b1FEFC98Ee16934DB03297B351FeF2ddb3866
@rordi
rordi / crontab.md
Last active October 24, 2017 14:26
Give crontab access to env variables of www-data user within a Docker container

Give crontab access to env variables of www-data user within a Docker container

docker entrypoint

CRON_ENV=/var/www/env.sh
printenv | sed 's/^\(.*\)$/export \1/g' > ${CRON_ENV}
@rordi
rordi / docker-debug.md
Last active April 29, 2024 12:45
Docker debugging an existing image

Debugging a Docker image

Start up the Docker container from image:

docker run --entrypoint "/bin/sh" --rm imagename:latest -c "sleep 24h"

Obtain the container hash id:

docker ps
@rordi
rordi / ahvn13-validation.js
Last active July 31, 2020 12:35
Javascript-based validation of Swiss AHV numbers AHVN13 / EAN13 [Validierung von Schweizer AHV Nummern mit Javascript]
/**
* Javascript-based validation of Swiss AHV numbers AHVN13 / EAN13
* [Validierung von Schweizer AHV Nummern mit Javascript]
*/
var inp = document.getElementById('ahvn13');
inp.addEventListener('change', _validateAhvn13);
var _validateAhvn13 = function(input) {
var pattern = /^756\.(\d{4})\.(\d{4})\.(\d{2})$/; // format is 756.0000.0000.00