Skip to content

Instantly share code, notes, and snippets.

Doeke Zanstra doekman

Block or report user

Report or block doekman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
doekman /
Last active Mar 8, 2019
Prints the URL of the remote origin of the current git repository
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
function git_url_to_https {
local git_url
if [[ $git_url =~ ^git@([^:]+):(.+)(\.git)?$ ]]; then
doekman /
Created Jan 2, 2019
Shows the `awesomecsv` list by using `ok-bash` in the terminal (and navigate to these links too)
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
function to_ok_format {
python -c "import codecs, csv, sys
def ansi_format(start, text, end): return '\x1B[{}m{}\x1B[{}m'.format(start, text, end)

Keybase proof

I hereby claim:

  • I am doekman on github.
  • I am doekman ( on keybase.
  • I have a public key ASDhb5zNrn5eL3RhB4nBo_1cfnuGQTArjuOMtBi-mUt_tQo

To claim this, I am signing this object:

doekman /
Created Nov 28, 2017
Determine the used language of an `.scpt` file
#!/usr/bin/env bash
function usage {
echo "Usage: $(basename $0) $1 [-n|-i|-a]
-n or --name: show name of language (default)
-i or --id: show id of language
-a or --all: show 'id:name' of language
-e or --error: (for TESTING) to generate an AppleScript error"
doekman /
Last active Oct 5, 2017
A replacement for `logging.handlers.SMTPHandler` that integrates with Flask-Mail
import logging
from enum import Enum
def _has_newline(line):
"""Used by has_bad_header to check for \\r or \\n"""
if line and ('\r' in line or '\n' in line):
return True
return False
def _is_bad_subject(subject):
doekman /
Last active Jun 12, 2019
Add support for page overlays to support non-trivial page headers/footers in Flask-WeasyPrint

Paged media CSS doesn't support more complex page header/footer requirements, like tables. A solution to this is to create a separate page with such a header, and merge this into the PDF on the required pages. A proof of concept was written by pikhovkin in this Gist.

Overlay: Represents one HTML page to be overlaid on a PDF document.

  • template_name_or_list: the name of the HTML template, which is resolved with jinja2's get_or_select_template method.
  • fn_include_on_page: a function that takes a 0-based page number, and returns a boolean that indicates if it needs to be included on that page.
  • kwargs: context used to render the overlay. Can also be used to dynamically position content.
doekman /
Last active Jan 2, 2019
Command-line program that sorts standard input as a human would expect.
# Rewrite from python ;-)
alias human_sort="sort --version-sort --ignore-case"
doekman /
Created Dec 19, 2016
Update all git repositories in direct subdirectories
#!/usr/bin/env bash
find . -maxdepth 1 -mindepth 1 -type d | while read i; do (cd "$i"; if [[ -d ".git" ]]; then echo "Checking $i" && git pull; fi; cd ..); done
doekman / iambored.py3
Created Jul 19, 2016
Opens one item from secretGeek's best-of-wikipedia listing in your favorite browser.
View iambored.py3
#!/usr/bin/env python3
# Tested on OS X
from lxml import html
import requests
import random
from subprocess import call
page = requests.get('')
View trim.applescript
on trim(theseCharacters, someText)
if class of someText is text and length of someText > 0 then
-- default values (all whitespace)
if theseCharacters is true then ¬
set theseCharacters to {" ", tab, ASCII character 10, return, ASCII character 0}
repeat until first character of someText is not in theseCharacters
set someText to text 2 thru -1 of someText
end repeat
You can’t perform that action at this time.