Skip to content

Instantly share code, notes, and snippets.

View rordi's full-sized avatar
🎓

Dietrich Rordorf rordi

🎓
View GitHub Profile
@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}
0xAd9b1FEFC98Ee16934DB03297B351FeF2ddb3866
@rordi
rordi / selenium-chrome-options.js
Last active August 20, 2019 15:28
Javascript Selenium Web Driver with Chrome Options
const {Builder, By, Capabilities} = require('selenium-webdriver');
let chromeCapabilities = Capabilities.chrome();
let chromeOptions = {
'args': ['--test-type', '--headles', '--incognito', '--window-size=340,750'] // approx. size of an iPhone 5/SE
};
// "chromeOptions" was changed to "goog:chromeOptions" at some point...
chromeCapabilities.set('goog:chromeOptions', chromeOptions);
@rordi
rordi / Operator-Mono-Dark-patched-didi.itermcolors
Created August 28, 2019 12:21
patched Operator Mono Dark colors for iterm
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.35364818572998047</real>

MariaDB / MySQL Cheatlist

Import a dump file:

mysql -u userName --password=yourSecret dbName < ./path/to/dump.sql

Run command non-interactive:

mysql -u userName --pasword=yourSecret dbName -e 'SELECT * FROM my_table;'
@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
@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
@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 / 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 / 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 */