Skip to content

Instantly share code, notes, and snippets.

View rordi's full-sized avatar
🎓

Dietrich Rordorf rordi

🎓
View GitHub Profile
@rordi
rordi / root-password-MariaDB-docker-compose.md
Last active January 23, 2024 15:36
Change root password in MariaDB Docker container running with docker-compose

Change root password in MariaDB Docker container running with docker-compose

Override the entrypoint in docker-compose.yml for the MariaDB Docker container by adding:

entrypoint: mysqld_safe --skip-grant-tables --user=mysql

The start up the Docker Compose stack:

$> docker-compose up -d

Remove a large file from previous git commit / GitHub

E.g. when accidentally committing a large file to a git repo and GitHub refises the commit.

git filter-branch --tree-filter 'rm -f path/to/large/file' HEAD

Afterwards, simply try to push to GitHub again...

@rordi
rordi / docker-debug.md
Last active December 5, 2023 09:35
Docker debugging an existing image

Debugging a Docker image

Start up the Docker container from image:

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

Obtain the container hash id:

docker ps
@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

Tensorflow & Keras in RStudio on Apple M1 or M2 (arm64) Chips

The problem is not M1 or M2 (arm64) chipset. The problem is keras installation that installs tensorflow-metal, which makes Keras to choose GPU over CPU, even if Sys.setenv("CUDA_VISIBLE_DEVICES" = -1) is set. However, Apple's GPUs are not supported yet by tensorflow-metal. Thus, we have to get rid of tensorflow-metal! Combined with R / RStudio, the trick is to use a dedicated r-reticulate environment to run python and to manually uninstall tensorflow-metal again, which is installed automatically whenever we install and load the keras package in R.

Install Anaconda for arm64 first: https://docs.anaconda.com/anaconda/install/mac-os/

@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
@rordi
rordi / wordpress-proxy.md
Last active September 16, 2021 11:52
Run Wordpress behind a proxy server (avoid assets being blocked)

Run Wordpress behind a proxy server (avoid assets being blocked)

Wordpress has issues to detect the SSL connection betwenn the client and the proxy and thus may load static assets through http instead https, which will be blocked in moderns browsers (mixed content).

To circumvent the problem, simly extend your wp-config.php by following functions (insert towards the top of the config script):

/** Proxy SSL detection */

@rordi
rordi / config.user.inc.php
Last active June 23, 2021 15:59
Configuration hardening for PhpMyAdmin
<?php
/**
* Configuration hardening for PhpMyAdmin
*
* This file is included at the end of the main PhpMyAdmin configuration file. We thus here override
* any potential config value that was previously set.
*
* @author Dietrich Rordorf
* @date 2018-11-05
* @see https://docs.phpmyadmin.net/en/latest/config.html
@rordi
rordi / hugo-prev-next-navigation-custom-section.order.md
Last active April 18, 2021 18:33
Previous / Next Navigation in Hugo with custom section order

Previous/Next navigation in Hugo with custom order based on param / attribute

This gist let's you return previous/next pages based on a frontmatter parameter in Hugo. In this exmaple, the frontmatter parameter is called position, where lower positions come first.

This prev / next navigation is looping: if there is no "next >" entry anymore, the first entry of the collection will be linked. Same for "< prev": if there is no previous element, the last element of the collection will be linked.

<div class="nav-prev-next">
    {{ $currentSection := (($.Site.GetPage "section" .Section).Pages.ByParam "position") }}
@rordi
rordi / git-commit.md
Last active September 16, 2020 07:40
Commands to get basic info about a git commit

Commands to get basic info about a git commit

  • Deploy Timestamp: date +"%Y-%m-%d %H:%M:%S"
  • Git Repo: basename `git rev-parse --show-toplevel`
  • Git Branch: git rev-parse --abbrev-ref HEAD
  • Git Commit Long Hash: git rev-parse HEAD
  • Git Commit Short Hash: git rev-parse --short HEAD