Skip to content

Instantly share code, notes, and snippets.

Avatar

Rick Companje companje

View GitHub Profile
@companje
companje / ocr mac.py
Created April 25, 2023 11:59
ocr mac
View ocr mac.py
#!/Applications/Xcode.app/Contents/Developer/usr/bin/python3
import config,json,os,subprocess,ocr2json
from tqdm import tqdm
from joblib import Parallel, delayed
import Quartz,Vision
from Cocoa import NSURL
from Foundation import NSDictionary
from wurlitzer import pipes # needed to capture system-level stderr
@companje
companje / load-link-filter.js
Created October 26, 2022 07:27
load, link and filter data in javascript from triplestore
View load-link-filter.js
@companje
companje / Understanding-City-in-a-bottle.pde
Last active October 2, 2022 19:27
Understanding 'City in a bottle' in Processing
View Understanding-City-in-a-bottle.pde
//Original by Frank Force (KilledByAPixel) - https://twitter.com/KilledByAPixel/status/1517294627996545024.
//Observable by Daniel Darabos - https://observablehq.com/@darabos/decoding-a-city-in-a-bottle
//Processing version by Rick Companje as intermediate step to 8086 assembly language.
//this version currently lacks textures on the buildings. To be continued.
int w=72;
int h=50;
int t=0;
void setup() {
@companje
companje / data.ttl
Created August 16, 2022 11:28
geof:sfWithin (filter results with a boundingbox) with SPARQL
View data.ttl
@prefix geo: <http://www.opengis.net/ont/geosparql#> .
@prefix def: <https://hetutrechtsarchief.nl/def/> .
@prefix hua: <https://hetutrechtsarchief.nl/id/> .
hua:D8884A3B2E6CA8F6E0538F04000A374B
a def:Adresvermelding ;
geo:asWKT "POINT (9.1825624999999995 45.4652869999999965)"^^geo:wktLiteral .
@companje
companje / Mercury-Elevation-map-waterlevel.pde
Created August 11, 2022 14:21
Mercury Elevation map waterlevels /
View Mercury-Elevation-map-waterlevel.pde
//based on Mercury MESSENGER Global DEM 665m v2
//https://web.archive.org/web/20210903191157/https://astrogeology.usgs.gov/search/map/Mercury/Topography/MESSENGER/Mercury_Messenger_USGS_DEM_Global_665m_v2
PImage palette, heightmap, colormap, normalmap;
PShader shader;
float progress = 0;
void setup() {
size(2048, 1024, P3D);
shader = loadShader("shader.glsl");
@companje
companje / ExpressionParser.py
Last active August 8, 2022 21:57
Expression Parser - Bauer-Samelson algorithm as described in BYTE magazine 1976-02
View ExpressionParser.py
```
# Expression Parser - Bauer-Samelson algorithm as described in BYTE magazine 1976-02
# Python implementation: Rick Companje, 30 July 2022
# usage: main("20+4*(5-(6-3))/8")
import math,re
def precedence_check(operators,c):
if not operators or operators[-1] == '(':
return True
@companje
companje / straatnamen.geojson
Created June 21, 2022 12:19
straatnamen.geojson
View straatnamen.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@companje
companje / fuzzy-matching.py
Created June 15, 2022 15:16
Fuzzy matchen in strings
View fuzzy-matching.py
#!/usr/bin/env python3
import json
from fuzzysearch import find_near_matches
from fuzzywuzzy import process
json_file = "A152153-pagina5tm20/page/NL-UtHUA_A152153_000005-f.json"
def fuzzy_extract(qs, ls, threshold):
'''fuzzy matches 'qs' in 'ls' and returns list of
@companje
companje / 1-Kadaster-zoekschil-conversie.py
Last active June 14, 2022 10:17
Kadaster-zoekschil-conversie
View 1-Kadaster-zoekschil-conversie.py
#!/usr/bin/env python3
import csv,os
from collections import defaultdict
rows = [ row for row in csv.DictReader(open("kadaster.csv")) ]
# "id","gemeente","arrondissement","dvd_nr","dvd_code","soort","leggerart","begin","eind","begino","eindo","invnr","reeksdeel","Sectie","pad","filenaam","naam1","naam2"
file_paths = defaultdict(list)
@companje
companje / Conway Game of Life.pde
Last active June 8, 2022 23:47
Conway Game of Life - 321 bytes in Processing - Code Golf submission
View Conway Game of Life.pde
/*
Rick Companje, 2022-06-09, MIT
Code Golf submission: Shortest Game of Life
289 bytes in Processing/Java
https://codegolf.stackexchange.com/questions/3434/shortest-game-of-life
grid 100x100
grid wraps around
draw custom pattern with mouse
*/