Skip to content

Instantly share code, notes, and snippets.

@doekman
doekman / trello.css
Created February 4, 2021 08:57
Add this as user-defined stylesheet to your browser for use with https://trello.com
/*Trello rule*/
.card-label .label-text::after {
content: ' ⚪️'; /*clear label*/
}
.card-label-green .label-text::after {
content: ' 🟢';
}
.card-label-yellow .label-text::after {
content: ' 🟡';
}
@doekman
doekman / json-pp.py
Last active October 5, 2020 18:29
Pretty Print JSON with a Twist
#!/usr/bin/env python3
# See blog article:
# https://blog.zanstra.com/2020/10/05/Pretty-printing-JSON-with-a-twist.html
import json, re, sys
def json_stringify(obj, indent=2):
if not isinstance(indent, str):
indent = ' ' * indent
@doekman
doekman / blog_2020-04-03.md
Last active April 3, 2020 20:14
This gist exists solely to enable comments on my blog post. When comments are going to be closed, the comments will be added to the static website.

Query Trello data with Postgres (JSON)

Recently, I was working on a project to automatically create Trello-cards via their API. To do that, I needed some id-values from the Trello-board which are not shown in the user-interface. But where does one get these values?

Glad you asked. Every Trello-board can be [exported to JSON][trello_export], and the values I was looking for are available in this export. However, JSON gives you the data in one big piece of text. Wouldn't it be handier to have it available as tabular data in a database?

So I created [this git-repository][git_repo] to do just that (you will need the [Postgres][postgresql]-database for this).

The table in which the JSON is stored, is modelled after an [idea of Rob Conery][conery] which basically is: store the JSON in a column, along with another column that uniquely identifies the document. This unique value is also available within the JSON itself.

@doekman
doekman / ok-bash.rb
Created January 27, 2020 10:00
Brew formula for ok-bash for when we are more notable.Create with `brew create --python https://github.com/secretGeek/ok-bash/archive/v0.8.1.tar.gz`
class OkBash < Formula
desc ".ok folder profiles for bash"
homepage "https://github.com/secretGeek/ok-bash"
url "https://github.com/secretGeek/ok-bash/archive/v0.8.1.tar.gz"
sha256 "ec2d65dc617948d071012b7076f47fa0e23e2f47bf3b56ee07a7c5978dd07b50"
bottle :unneeded
def install
(prefix/"etc/profile.d").install "ok.sh"
@doekman
doekman / netnewswire-convert.sh
Last active August 25, 2019 19:17
Convert git-log to markdown (NetNewsWire)
#!/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 December 4, 2019 16:06
Prints the URL of the remote origin of the current git repository, optionally with a SHA1 commit
#!/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 June 7, 2020 11:13
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
IFS=$'\n\t'
# import ok
if [[ -r "$_OK__PATH_TO_ME/ok.sh" ]]; then
. "$_OK__PATH_TO_ME/ok.sh" prompt '=> ' prompt_default
fi

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 November 28, 2017 14:24
Determine the used language of an `.scpt` file
#!/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 September 28, 2021 10:08
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):