Skip to content

Instantly share code, notes, and snippets.

@k-nut
k-nut / criticaltracks-cleanup.py
Last active June 27, 2022 16:58
CriticalTracks
import sqlite3
import json
import sys
FILENAME = "./criticaltracks.sqlite"
def get_distane(point, other_point):
from math import sin, cos, sqrt, atan2, radians
// When a user views a map on a webiste, they probably want to see the map in relation to their current position.
// This snippets gets the user location and then tells the Leaflet map to fit the user location into the current view.
// This way, the developer of the website can create their map as always, setting a sensible default view.
// On page load, the user will be prompted for their location. If they give it, the map will zoom out so far
// that the user location as well as the original marker are visible.
// This way, if a user from another country views the map, they get a quick understanding for where this point
// is at all whereas a local can immediately see the precise position.
const myMap = L.map('mapid').setView([51.505, -0.09], 13);

Keybase proof

I hereby claim:

  • I am k-nut on github.
  • I am knut (https://keybase.io/knut) on keybase.
  • I have a public key ASC4q_VgMgEKgz1UEGK8JV8OmdfNRzZPc_xyadnjckLemgo

To claim this, I am signing this object:

@k-nut
k-nut / pdf-split-and-collect.fish
Created March 16, 2019 12:18
Tax Time PDF collector
set tmp_dir (mktemp -d) # create a temporary directory
for file in (ls Account*.pdf) # match all files to be included
pdfseparate $file $tmp_dir/$file--%03d.pdf # split pdfs page wise into tmp dir
end
for file in (ls $tmp_dir/*.pdf) # iterate through all split pages
if pdftotext $file - | grep 'EUROPEAN' # check if they contain our search string
set matches $matches $file # append to our match list
end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@k-nut
k-nut / reorder-duplex-scan.sh
Created April 21, 2018 06:37
Turn a scanned duplex pdf [1,2,3,5,6,4] into the correct order [1,2,3,4,5,6]
#!/bin/sh
FILENAME="$1"
COUNT=$(pdfinfo "$FILENAME" | awk '$1 == "Pages:" {print $2}')
HALF=$((COUNT/2))
ARGUMENTS=""
for i in $(seq 1 $HALF)
do
ARGUMENTS="$ARGUMENTS Reorder-Page-$i.pdf"
done
let targetDate = new Date(2017, 8, 26, 0, 0, 0, 0)
let rem = Application('Reminders').lists.byName('Test').reminders();
rem
.filter(reminder => reminder.completionDate() < targetDate)
.map(reminder => reminder.name());
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
SUMMARY:Registrierung der Teilnehmenden
DTSTART;TZID=Europe/Berlin:20170428T090000
DTEND;TZID=Europe/Berlin:20170428T100000
STATUS:CONFIRMED
SEQUENCE:1
END:VEVENT
@k-nut
k-nut / create_politician.py
Created December 4, 2016 09:14
Create a new politician
import pywikibot
def create_bavarian_politician(name):
"""
Creates a new entry in test.wikdata.org
:return:
"""
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
@k-nut
k-nut / landtagify.py
Last active December 3, 2016 21:20
Add a Politician to the 16th Landtag in NRW
# -*- coding: utf-8 -*-
import pywikibot
import json
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
def mark_as_part_of_current_landtag(politican_item_id):
item = pywikibot.ItemPage(repo, politican_item_id)
claims = item.get()['claims']['P39']