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
doekman / netnewswire-convert.sh
Last active Aug 25, 2019
Convert git-log to markdown (NetNewsWire)
View netnewswire-convert.sh
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS=$'\n\t'
function group_on_date {
awk $'NR==1 {
cur_year=substr($1,1,4)
cur_month=substr($1,6,2)
printf "## %s\\n", cur_year
@doekman
doekman / git-url.sh
Last active Jul 7, 2019
Prints the URL of the remote origin of the current git repository
View git-url.sh
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS=$'\n\t'
function git_url_to_https {
local git_url
git_url=$(cat)
if [[ $git_url =~ ^git@([^:]+):(.+)(\.git)?$ ]]; then
@doekman
doekman / awesomecsv.sh
Last active Jul 15, 2019
Shows the `awesomecsv` list by using `ok-bash` in the terminal (and navigate to these links too)
View awesomecsv.sh
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS=$'\n\t'
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)
View keybase.md

Keybase proof

I hereby claim:

  • I am doekman on github.
  • I am doekman (https://keybase.io/doekman) on keybase.
  • I have a public key ASDhb5zNrn5eL3RhB4nBo_1cfnuGQTArjuOMtBi-mUt_tQo

To claim this, I am signing this object:

@doekman
doekman / osagetlang.sh
Created Nov 28, 2017
Determine the used language of an `.scpt` file
View osagetlang.sh
#!/usr/bin/env bash
function usage {
echo "Usage: $(basename $0) $1 [-n|-i|-a]
Arguments:
-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
doekman / flask_mail.py
Last active Oct 5, 2017
A replacement for `logging.handlers.SMTPHandler` that integrates with Flask-Mail
View flask_mail.py
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
doekman / README.md
Last active Jun 12, 2019
Add support for page overlays to support non-trivial page headers/footers in Flask-WeasyPrint
View README.md

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
doekman / human_sort.sh
Last active Jan 2, 2019
Command-line program that sorts standard input as a human would expect.
View human_sort.sh
# Rewrite from python ;-)
alias human_sort="sort --version-sort --ignore-case"
@doekman
doekman / pull-all.sh
Created Dec 19, 2016
Update all git repositories in direct subdirectories
View pull-all.sh
#!/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
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('http://wiki.secretgeek.net/best-of-wikipedia')
You can’t perform that action at this time.