Skip to content

Instantly share code, notes, and snippets.


Knud Möller knudmoeller

View GitHub Profile
import subprocess
# read the dictionary file:
result =['egrep', '^.{5}$', "/usr/share/dict/words"], stdout=subprocess.PIPE)
words = result.stdout.decode('utf-8').splitlines()
present = ['a', 'n', 'g', 't'] # letters that we know are in the word
not_present = ['o', 'i', 's', 'e', 'u'] # letters we know are not in the word
# filter words with all() and not any()
  • Input data are multiple json files in sorted/ with this minimal structure:
  "dump_finished": "2021-12-14T10:43:42+01:00",
  "datasets": [
knudmoeller /
Created Dec 21, 2021
Query multiple files with jq, slurp results into one large array
jq "{date: .dump_finished, count: .datasets | length}" sorted/*.json | jq -s
knudmoeller /
Created Nov 18, 2021
Bulk-purging Datasets in CKAN with ckanapi
from ckanapi import RemoteCKAN
import os
# require ckanapi:
package_names = [
knudmoeller /
Created Oct 21, 2020
Drush/SQL command to count number of nodes for each node type
drush sqlq 'select count(node.nid) as node_count, node_type.type from node inner join node_type on node.type = node_type.type group by node_type.type'
knudmoeller /
Last active Jan 22, 2022
Perform OR queries for categories on Microsoft Outlook for Mac

Perform OR queries for categories on Microsoft Outlook for Mac

Bizarrely, one cannot make OR queries in Microsoft Outlook for Mac, at least not easily. For example, I want a smart folder that contains all messages tagged with either the FIS Broker category or the Dubletten category.

The way to do it non-easily is to select Raw Query as the query rule type (in Search > Advanced), and then enter a Spotlight query string. The attribute to query for categories is com_microsoft_outlook_categories. That attribute takes a numeric id - but what the hell is the id for a category like FIS Broker? Outlook doesn't tell me, so I have to go even deeper down the rabbit hole. Here is how:

knudmoeller /
Created Mar 11, 2020
Get the most recent data updates in Berlin's Open Data Portal
# The CKAN Action-API endpoint:
# Query filtering datasets that came in through the FIS-Broker harvester
# date_updated refers to the when the data (not the metadata) was updated last
knudmoeller /
Last active Jan 6, 2020
bash command to retrieve index of last page for DCAT catalog endpoint
curl ${BASE_URI}/catalog.jsonld | jq -r '.[] | select(."@id" | endswith("/catalog.jsonld?page=1")) | ."" | .[0]."@value" | split("=") | .[1]'
knudmoeller / unescape.rb
Created Jan 3, 2020
Unescape URI-escaped file line by line to STDOUT
View unescape.rb
require 'cgi'
filename = ARGV[0] { |line| puts CGI.unescape(line) }
knudmoeller / victoriapark_tree.geojson
Created Oct 26, 2019
Bäume im Viktoriapark in Berlin
View victoriapark_tree.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.