Skip to content

Instantly share code, notes, and snippets.

View knudmoeller's full-sized avatar

Knud Möller knudmoeller

View GitHub Profile
@knudmoeller
knudmoeller / wahlkreise.geojson
Last active May 23, 2019 09:34
Wahlkreise Europawahl 2019
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knudmoeller
knudmoeller / victoriapark_tree.geojson
Created October 26, 2019 10:59
Bäume im Viktoriapark in Berlin
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knudmoeller
knudmoeller / unescape.rb
Created January 3, 2020 15:40
Unescape URI-escaped file line by line to STDOUT
require 'cgi'
filename = ARGV[0]
File.open(filename).each { |line| puts CGI.unescape(line) }
@knudmoeller
knudmoeller / dcat-catalog-lastpage.sh
Last active January 6, 2020 16:18
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")) | ."http://www.w3.org/ns/hydra/core#lastPage" | .[0]."@value" | split("=") | .[1]'
@knudmoeller
knudmoeller / recent_data_updates.sh
Created March 11, 2020 16:24
Get the most recent data updates in Berlin's Open Data Portal
#!/bin/bash
# The CKAN Action-API endpoint:
DATENREGISTER_API_BASE="https://datenregister.berlin.de/api/3/action/"
# Query filtering datasets that came in through the FIS-Broker harvester
QUERY="berlin_source:harvest-fisbroker"
# date_updated refers to the when the data (not the metadata) was updated last
SORT="date_updated+desc"
@knudmoeller
knudmoeller / or_queries_for_outlook_categories.md
Last active January 30, 2023 12:44
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
knudmoeller / drush_count_nodes.sh
Created October 21, 2020 15:26
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
knudmoeller / bulk_purge.py
Created November 18, 2021 08:57
Bulk-purging Datasets in CKAN with ckanapi
from ckanapi import RemoteCKAN
import os
# require ckanapi: https://github.com/ckan/ckanapi
package_names = [
"versickerung-aus-niederschlagen-2017-umweltatlas-wfs-beb56dfa",
"versickerung-aus-niederschlagen-ohne-versiegelung-2017-umweltatlas-wfs-e4a931f6",
"versiegelung-2005-unkorrigierte-versiegelungsgrade-rasterdaten-atom-451f714b",
"versiegelung-2011-unkorrigierte-versiegelungsgrade-rasterdaten-atom-c973b948",
@knudmoeller
knudmoeller / jq_multi_query.sh
Created December 21, 2021 13:59
Query multiple files with jq, slurp results into one large array
jq "{date: .dump_finished, count: .datasets | length}" sorted/*.json | jq -s