Skip to content

Instantly share code, notes, and snippets.

View tommorris's full-sized avatar

Tom Morris tommorris

View GitHub Profile
@tommorris
tommorris / pubfinding.duck.sql
Created April 3, 2024 16:18
QuackOSM + DuckDB + GeoParquet for rapid pub location
-- 1. install QuackOSM and DuckDB
-- 2. get a city/country pbf from http://download.geofabrik.de/
-- 3. run `quackosm ./greater-london-latest.osm.pbf` and wait
-- 4. run `duckdb` and...
install spatial;
load spatial;
select *,
tags['name'] as poi_name,
@tommorris
tommorris / pdf_extract.py
Last active March 9, 2024 07:37
a simple script to extract nested PDFs (aka "PDF Portfolios") using pypdf
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python311 python311Packages.pypdf
import sys
from pypdf import PdfReader
def extract_subpdfs():
for filename in sys.argv[1:]:
print("Extracting " + filename)
root_doc = PdfReader(open(filename, "rb"))
@tommorris
tommorris / init.lua
Created March 8, 2023 13:29
Hammerspoon rules for binding pedals
require('util')
pedal_rules = {
l = {
{
name = "Google Meet (show chat)",
predicate = isAppRunning("Google Chrome"),
action = hs.fnutils.partial(dispatchCommandToChrome, {'ctrl', 'cmd'}, 'c'),
},
{
@tommorris
tommorris / follow.sparql
Created February 15, 2023 17:53
wikidata query for follows/followed by mistakes
# finds all things that have a "follows" or "followed by" relationship, where the thing it follows is a year.
# these exist because parsers pulled next/prev links from wikipedia and decided to infer the thing it follows is a year.
# action: check and remove
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?a ?aLabel ?aType ?aTypeLabel ?b ?bLabel
@tommorris
tommorris / 01-a-Makefile.mk
Last active January 27, 2023 13:18
Makefile examples used in blogpost
pkg="a"
include "../shared/base.mk"
<i id="latin-text-1" lang="la" typeof="schema:CreativeWork" about="#latin-text-1" property="schema:text">veni vidi vici</i>
(<span typeof="schema:CreativeWork">
<data property="schema:translationOfWork" resource="#latin-text-1" />
<span property="schema:text" lang="en">I came, I saw, I conquered</span>
</span>)
// ==UserScript==
// @name Add underlines to keyboard in keybr
// @version 1
// @match *://keybr.com/
// @match *://keybr.com/*
// @match *://www.keybr.com/
// @match *://www.keybr.com/*
// @grant none
// ==/UserScript==
@tommorris
tommorris / _prj.sh
Created February 4, 2022 15:44
use emacs projectile known projects list for command line project switching
#!/bin/bash
# alias in your zshrc as
# alias prj="source ~/bin/_prj"
DIR=`cat ~/.emacs.d/.local/cache/projectile.projects | sed 's/" "/\n/g' | sed 's/[\"\(\)]//g' | fzf | xargs -n 1 python -c 'import os, sys; print(os.path.expanduser(sys.argv[1]))'`
cd $DIR
@tommorris
tommorris / filenotify-projectile.el
Created January 18, 2022 21:42
use filenotify to invalidate projectile cache
(require 'filenotify)
(after! projectile
(dolist (proj-dir projectile-known-projects)
(file-notify-add-watch proj-dir '(change) #'projectile-maybe-invalidate-cache)))
@tommorris
tommorris / dbt_model_with_jinja.sql
Last active January 6, 2022 08:08
Multi-mode example
{{ config(
materialized="view",
schema="marketing")
}}
with customer_orders as (
select
customer_id,