Skip to content

Instantly share code, notes, and snippets.

View knudmoeller's full-sized avatar

Knud Möller knudmoeller

View GitHub Profile
@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 / 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 / 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 / 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 / berlin_open_data_example.geojson
Last active May 16, 2019 14:41
Example Data from daten.berlin.de
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knudmoeller
knudmoeller / get_editble_thing.rq
Last active March 7, 2019 16:28
Wikidata Query to find edible products of plants
SELECT ?ediblething ?ediblethingLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
wd:Q158657 wdt:P171+ ?parent_taxon . # Q158657 is "Malus pumila", the tree we want to find fruit for
?ediblething
wdt:P1582 ?parent_taxon ;
wdt:P279 ?superthing .
?superthing wdt:P361 wd:Q21925565 .
}
LIMIT 100
@knudmoeller
knudmoeller / export_ckan.rb
Last active January 10, 2019 09:56
Ruby script to generate a JSON dump of all CKAN datasets, using the CKAN API via HTTP.
# coding: utf-8
require 'json'
require 'uri'
require 'net/https'
require 'optparse'
require 'logger'
# Send an HTTP request, interprete response as JSON
# and return as Ruby object.
@knudmoeller
knudmoeller / create_tar.sh
Created December 20, 2018 09:22
I keep forgetting the order of the parameters.
tar -cvzf $ARCHIVE_NAME.tgz $CONTENT_1 $CONTENT_2 ...
@knudmoeller
knudmoeller / json2csv.md
Last active July 12, 2023 07:43
Turn a JSON array into CSV

input data.json

[
  {
    "id": 0 ,
    "foo": "bar"
  } ,
  {
    "id": 1 ,