Skip to content

Instantly share code, notes, and snippets.


Roy de Jong roydejong

View GitHub Profile
roydejong / mysql-backup-to-s3
Last active Aug 13, 2021
Cron script: MySQL Nightly Backups to S3
View mysql-backup-to-s3
# /etc/cron.daily/mysql-s3-backup
# Before use, install AWS CLI and use "aws configure" to set up credentials with write access to your s3 bucket
# See
roydejong /
Last active Jan 22, 2021
Commit message conventions


Consistent commit messages that are easily readable & searchable.


commit_type(project_component): [issue_reference] short_message 

roydejong /
Last active Jan 18, 2022
Installing ProGrids v3 in Unity 2018.3

The problem

ProGrids seems to have disappeared from the Unity Package Manager as of Unity 2018.3.

It is possible to install ProGrids v2 via the Asset Store, but it's an old and incompatible version.

The solution

As per the comments below:

There's a simpler way to get ProGrids to show up in 2018.3: Just enable Advanced > Show preview packages in the Package Manager.

The solution (old)

roydejong / is_touch_device.js
Created Jan 7, 2019
JavaScript: Detect touch device (react compatible)
View is_touch_device.js
function is_touch_device() {
try {
let prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
let mq = function (query) {
return window.matchMedia(query).matches;
if (('ontouchstart' in window) || (typeof window.DocumentTouch !== "undefined" && document instanceof window.DocumentTouch)) {
return true;
roydejong / UnityDiscordRPCDebugLogger.cs
Last active Jan 7, 2019
Unity: Debug logger class for the DiscordRPC C# Wrapper Library
View UnityDiscordRPCDebugLogger.cs
using DiscordRPC.Logging;
using System;
using UnityEngine;
public class DiscordDebugLogger : DiscordRPC.Logging.ILogger
/// <summary>
/// The level of logging to apply to this logger.
/// </summary>
public LogLevel Level { get; set; }
roydejong / NativeWinAlert.cs
Last active Jan 20, 2023
Unity: NativeWinAlert (Windows MessageBox / Alert Dialog for Unity games)
View NativeWinAlert.cs
using System;
using System.Runtime.InteropServices;
/// <see></see>
public static class NativeWinAlert
private static extern System.IntPtr GetActiveWindow();
public static System.IntPtr GetWindowHandle()
roydejong / floatval-locale-guess.php
Last active May 1, 2022
PHP: Parse raw input as a float, with best guess for the decimal character (dot or comma). Useful if you do not know original locale or when you are processing user input.
View floatval-locale-guess.php
function parseFloatGuess($rawValue) {
if (!$rawValue) {
return 0;
$lastCommaPosition = strrpos($rawValue, ',');
$lastDotPosition = strrpos($rawValue, '.');
roydejong /
Last active Aug 18, 2021
Set up wkhtmltopdf 0.12.6 on Ubuntu server + xvfb runtime + PHP integration

1. Install wkhtmltopdf

Find the download URL for the latest binary from the official Downloads page.

At the time of writing, this is v0.12.6, which was released on June 11, 2020.

Download the binary, and then install the package and its dependencies. For example:

sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt install -f
roydejong / pouchdb-create-or-update-merge.js
Last active Jul 4, 2017
PouchDB: Add or update record (sync / merge)
View pouchdb-create-or-update-merge.js
static addOrUpdate(id, document) {
return new Promise(function (resolve, reject) {
let doStore = function (originalDocument) {
// Merge the document: First, set the ID. Then apply the existing doc on top if possible. Finally, apply the changed doc.
let mergedDoc = {
_id: id
if (originalDocument) {
for (let key in originalDocument) {
roydejong / map_country_to_continent.php
Created May 23, 2017
PHP: Array mapping country ISO codes to continent codes
View map_country_to_continent.php
$mapCountryToContinent = array(
"AF" => "AS",
"AX" => "EU",
"AL" => "EU",
"DZ" => "AF",
"AS" => "OC",
"AD" => "EU",
"AO" => "AF",
"AI" => "NA",
"AQ" => "AN",