Skip to content

Instantly share code, notes, and snippets.

View martijngastkemper's full-sized avatar

Martijn Gastkemper martijngastkemper

View GitHub Profile
#!/bin/sh
# Install OpenTTD on my RaspberryPi running Buster
## Download and extract
wget https://proxy.binaries.openttd.org/openttd-releases/1.9.2/openttd-1.9.2-source.tar.xz
tar -xf openttd-1.9.2-source.tar.xz
cd openttd-1.9.2
## Install without UI, because it's just a server
#!/bin/sh
# Usage: bash list-ports.sh PRIVATE_PORT
# PRIVATE_PORT default 80
privatePort=${1-80}
services=`docker-compose ps --service --filter "status=running" 2> /dev/null`
if [ -z "$services" ]
then
FROM r-base
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libxml2-dev \
libnetcdf-dev
@martijngastkemper
martijngastkemper / edit-multiple-files.bash
Created November 3, 2016 11:56
Edit multiple files with vim
vim `ls /home/*/public_html/.htaccess`
@martijngastkemper
martijngastkemper / replace.sh
Created November 1, 2016 07:41
Replace lines with sed
sed -i-backup "s/RewriteCond \%{HTTP_HOST}.*//" .htaccess
@martijngastkemper
martijngastkemper / acf-custom-rule.php
Last active October 30, 2016 14:12
Create a custom ACF rule to match all pages having a taxonomy enabled.
<?php
// functions.php
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
$choices['Post']['post-type-has-taxonomy'] = __('Post Type has Taxonomy');
return $choices;
}
add_filter( 'acf/location/rule_values/post-type-has-taxonomy', 'acf_location_rules_values_has_taxonomy' );
function acf_location_rules_values_has_taxonomy( $choices ) {
@martijngastkemper
martijngastkemper / csvkit-example.bash
Last active May 26, 2022 07:54
CSVkit example to convert CSV to SQLLite and query the data
# This example requires CSVkit (https://github.com/wireservice/csvkit). A Python toolset with a lot of very cool CSV tools.
# IMPORTANT NOTE: make sure to use a proper csv file. I had a lot of trouble with a csv file created by a service with Dutch
# as locale. Changing it to US solved the problem. Some locales use comma's to seperate point numbers. A semicolon is then
# used.
# Create table example and Load file-a.csv into it
csvsql --db sqlite:///example.db --table example --insert file-a.csv
# Add an extra file to table example
@martijngastkemper
martijngastkemper / buckaroo-json-api-authorization.php
Created June 10, 2016 09:34
A script to create an authorization string to connect with the Buckaroo JSON API.
<?php
$websiteKey = 'website-key';
$secretToken = 'secret-token';
$nonce = 'a-random-alphanumeric-string';
$requestBody = "{json: 'request'}";
$time = (string)time();
$parts = [
$websiteKey,
strtoupper('post or get'),
@martijngastkemper
martijngastkemper / gist:a84d874e97060f632978
Last active December 9, 2015 10:51
Convert adf binary to ascii whith GDAL on Mac OS
brew install gdal --with-python
brew install homebrew/python/numpy
gdal2xyz.py file-name.adf output.txt
# Windows:
cd folder/containing/gdal2zys
python gdal2xyz.py file-name.adf output.txt
@martijngastkemper
martijngastkemper / remove-first-br.php
Created November 9, 2015 14:43
Remove <br />, if it's the first word of a string.
trim(preg_replace("/^(<br \/>)/", "", $output, 1));