Skip to content

Instantly share code, notes, and snippets.

View oliver-la's full-sized avatar

oliver. oliver-la

View GitHub Profile
gpxpy==1.5.0
@oliver-la
oliver-la / functions.php
Created January 5, 2023 14:11
WordPress: Include Taxonomies in Editor Link Selection Modal at the backend
<?php
/**
* Filters the link query results. (Link Edit Modal in the editor)
* @see https://github.com/WordPress/WordPress/blob/3ba44120d0ffa7ac330a1b7e3f8b363ce78f8060/wp-includes/class-wp-editor.php#L1767
*/
add_filter(
'wp_link_query', function( array $results, array $query ) : array {
$terms = new WP_Term_Query(
[
@oliver-la
oliver-la / conv-svg.sh
Last active April 4, 2023 12:10
Bash Script to convert irregulary sized SVGs (different aspect ratio and sizes each) into 1:1 aspect ratio while also centering its contents
#!/bin/bash
INPUT="$1"
SIZE=$2
OUTPUT="$3"
INKSCAPE="${INKSCAPE:-/Applications/Inkscape.app/Contents/MacOS/inkscape}"
if [ -z "$INPUT" ] || [ -z "$SIZE" ] || [ -z "$OUTPUT" ]; then
echo "Usage: $0 [input] [size] [output]"
@oliver-la
oliver-la / spacing.scss
Created March 11, 2022 12:55
Bootstrap 5 ml-*, mr-*, pl-*, pr-* polyfill
/**
* Polyfill for ml-*, mr-*, pl-* and pr-* classes for bootstrap 5.
* Who tf can remember me-*, ms-*, etc?!
* Also removed the !important BS.
* Most of the source code comes from Bootstrap 4.
*/
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
@oliver-la
oliver-la / client.php
Created July 6, 2021 09:40
Swiss Postal Code Distance Search (PHP)
<?php
$max_distance_km = 5;
$max_locations = 10;
$base_location = array(
'longitude' => "-31.959138",
'latitude' => "115.858072"
);
$locations = [];

Gravity forms multi-column

  1. Each column should be prepended with a HTML block: no content, CSS-classes "col-12 col-lg-6 ...". col-12 is mandatory. (but by adjusting the script below you can make it optional)

https://i.imgur.com/IIEDMQc.png

@oliver-la
oliver-la / Boot server image virtually (with networking) from qcow2 - macOS.md
Created January 9, 2020 14:02
Boot server image virtually (w/ networking) from qcow2 - macOS

Install QEMU

brew install qemu

Convert qcow2 to vdi

qemu-img convert -O vdi one-img-147-2559-0-dsnap.qcow2 disk0.vdi

(if you have more disks, you need to convert them too and increase the disk number)

@oliver-la
oliver-la / create_m3u.sh
Created November 3, 2019 19:30
Creates m3u for soundiiz import for a given directory. The directory must recursively contain .flac files with the filename format: TRACKNUM - ARTISTNAME - TRACKNAME.flac
#!/bin/bash
PLAYLIST=$1
if ! [ -d "$PLAYLIST" ]; then
echo "Please enter a valid path"
exit
fi
echo "#EXTM3U" > "$PLAYLIST.m3u"
##
## Bundle of CA Root Certificates
##
## Certificate data from Mozilla as of: Wed Oct 16 03:12:09 2019 GMT
##
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
## file (certdata.txt). This file can be found in the mozilla source tree:
## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
##
@oliver-la
oliver-la / gist:e077bcb7ce94b1a00423b53265ff784f
Created August 29, 2019 11:51
Reads domains (line by line) from a file, and prints the first MX record of the domains in the same order they were given in the file to the terminal.
dig mx -f wl-domains.txt +noall +question +answer | sed -e '/;/s/^.//' | awk '{print $1" "$6"NOMX"}' | sed -e 's/\.NOMX//g' | tac | awk '!seen[$1]++' | tac | awk '{print $2}'