Skip to content

Instantly share code, notes, and snippets.

View a-ludi's full-sized avatar

Arne a-ludi

  • Sunfire GmbH
  • Germany
View GitHub Profile
@a-ludi
a-ludi / version_matches.sh
Created November 10, 2021 10:21
Compare a version against a set of match clauses
# Usage: version_matches <version> <clause>
#
# Params:
# <version> Dot-separated version specifier, e.g. 2.4.32
# <clause> Match-clause according to grammer (below), e.g. >=1.0.0&<2.0.0
#
# Grammar:
#
# <version> ::= <uint> | <uint> "." <version>
# <version_pred> ::= <version> | <op> <version>
@a-ludi
a-ludi / retry
Last active February 10, 2020 09:41
retry – retry a command until it succeeds
#!/bin/bash
# Unofficial Bash Strict Mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/)
set -euo pipefail
IFS=$'\n\t'
PROG="$(basename "$0")"
VERSION="0.1.0"
UPSTREAM_URL='https://gist.github.com/a-ludi/326a58b5a6b85c9c523833f614090438'
@a-ludi
a-ludi / hull_minkowski_bug.scad
Last active September 11, 2017 08:59
OpenSCAD: minkowski on non-convex objects produces geometry errors
// with errors due to minkowski with non-convex objects
translate([8, 0, 0])
difference() {
cube([15, 15, 1], center=true);
minkowski() {
for (i = [-1 : 1])
for (j = [-1 : 1])
translate(5*[i, j, 0])
cylinder(10, r=1, center=true);
function expectStruture(object, structure, breadcrumbs) {
var subStructure;
breadcrumbs = breadcrumbs || [];
structure = {
title: true,
description: true,
gallery: [{}],
eventTypeMood: true,
eventTypeLocation: true,
@a-ludi
a-ludi / db.php
Last active August 29, 2015 14:27
This is an extension to the default `wpdb` class providing some debugging facilities as well as `ez_*` family of functions for easy handling of MySQL queries.
<?php
/* Copyright © 2015 Arne Ludwig <arne.ludwig@posteo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@a-ludi
a-ludi / gpgedit
Last active July 23, 2023 21:19
gpgedit lets you edit a gpg-encrypted file without much fuzz -- similar to sudoedit.
#!/usr/bin/python
# gpgedit lets you edit a gpg-encrypted file without much fuzz -- similar to
# sudoedit.
#
# For this to achieve, gpgedit uses gpg to decrypt your file and save the
# plain text in a temporary file under /dev/shm (tmpfs) which will open in
# an editor. After the changes have been saved and the editor closed your
# plain text will be encrypted and written to the original file.
#
@a-ludi
a-ludi / yars
Last active July 10, 2017 07:51
Yet Another rsync Script
#!/bin/bash
# This script makes incremental or full backups of a given folder using rsync.
# Copyright (C) 2013 Arne Ludwig <ludwig.arne@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
@a-ludi
a-ludi / function_family_examples.gnu
Created August 22, 2013 13:47
Potting of Families of Curves and Palettes =============================== Further reading under http://wp.me/p31qg7-F
#!/usr/bin/gnuplot
set terminal pngcairo enhanced color \
font "cmr10,10" fontscale 1.3 \
size 890, 682
# Set the gaussian rgb-palette
G(x) = 0.855 * exp(-(x - 0.5)**2/0.25)
B(x) = 1.056 * exp(-x**2/0.49)
R(x) = B(1.0 - x)
@a-ludi
a-ludi / hide_todonotes
Last active December 21, 2015 06:49
This command adds two complemantary options `hide` and `show` to the `todonotes` package. If `hide` is given then the todo note itself will not be rendered, but a index entry will be created. **Usage:** while this is not part of the `todonote` package you can insert this snippet in your preample *after* the package has been loaded.
\makeatletter
\if@todonotes@disabled%
\else
\newif\if@todonotes@localhide\@todonotes@localhidefalse%
\define@key{todonotes}{hide}[]{\@todonotes@localhidetrue}%
\define@key{todonotes}{show}[]{\@todonotes@localhidefalse}%
\renewcommand{\@todo}[2][]{%
\if@todonotes@prependcaptionglobal%
\@todonotes@prependcaptiontrue%