Skip to content

Instantly share code, notes, and snippets.

View companje's full-sized avatar

Rick Companje companje

View GitHub Profile
@companje
companje / Sphere-Lat-Lon.pde
Last active January 29, 2025 08:01
Sphere with mouse and rotate to Lat Lon with Apache Math3 library
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
Vector3D nl = latLonToVector3D(52.37, 4.91);
Vector3D ny = latLonToVector3D(40.79, -73.96);
Vector3D zero = latLonToVector3D(0, 0.0001);
Vector3D north = latLonToVector3D(90, 0);
Vector3D south = latLonToVector3D(-90, 0);
Vector3D india = latLonToVector3D(8.2, 77.45);
Vector3D points[] = {nl, ny, zero, north, south, india};
@companje
companje / perspective.pde
Created January 21, 2025 10:58
perspective
float w=2160, h=2160, wd2=w/2, hd2=h/2, wdh=w/h;
float distToCam=1900;
perspective(atan(hd2/distToCam)*2, wdh, distToCam, 10000);
camera(0, 0, -distToCam, 0, 0, 0, 0, 1, 0);
scale(-1, 1, 1);
@companje
companje / sanyo-mbc-555-draw-bitmap-font.asm
Created December 21, 2024 23:37
Sanyo MBC-550/555 - draw bitmap font 12x12px anywhere on the screen
; see also https://companje.nl/sanyo
draw_char:
jmp .__________
; public
.char db 'A'
.ox dw 0
.oy dw 0
.width dw 16
.height dw 12
@companje
companje / wktLiteral to GeoJSON.py
Last active November 29, 2024 13:36
wktLiteral to GeoJSON met shapely
import json
from shapely import wkt
from shapely.geometry import mapping
with open('OSG.json', 'r') as infile:
data = json.load(infile)
geojson_features = []
for item in data:
@companje
companje / HISGIS-unrotate.py
Created November 26, 2024 10:09
HISGIS Unrotate - Automatische berekenen rotatiematrix via keypoint herkenning en vervolgens converteren van Ground Control Points
import cv2,sys,re,json
import numpy as np
from pathlib import Path
input_folder = "../TAB bestanden met afbeelding Ad"
for tab_filename in Path(input_folder).rglob("*.png"):
print(tab_filename)
sys.exit()
@companje
companje / Vitek-Beeldbank-search-results-to-IIIF-manifest.py
Last active October 25, 2024 11:43
Create IIIF Manifest to use in AllMaps - from Vitek Beeldbank search results
import json,requests
def create_iiif_manifest(json_data):
image_api = "https://maior-images.memorix.nl/utr/iiif/"
manifest_id = "https://iiif.hualab.nl/riool-en-huisnummer-kaart"
manifest = {
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": manifest_id,
"type": "Manifest",
@companje
companje / driver
Last active July 30, 2024 20:13
USB to HDMI drivers
deze stond in de beschrijving van de webshop: https://files-onlinekabelshop.nl/Handleidingen/OKS-42863_drivers.zip
ookal is de chipset van frescologic volgens de webshop, deze driver herkend de hardware niet: https://support.frescologic.com/portal/en/kb/articles/usb-3-0-v
deze werkt voor mij: https://github.com/MindShow/USBDisplay/blob/main/WinDows/MSDisplay_Windows_V2.0.1.7.3.exe
@companje
companje / streaming-json-objects-chatgpt-api.py
Last active October 22, 2024 07:05
parse ChatGPT API incoming streaming json objects with ijson
# thanks: https://til.simonwillison.net/json/ijson-stream
import json,openai,ijson
client = openai.OpenAI()
response = client.chat.completions.create(
model='gpt-4o',
response_format={ "type": "json_object" },
messages=[
@companje
companje / 0.spreadsheet.py
Created May 22, 2024 09:06
Spreadsheet GPT
import os,json,xlwt
import pandas as pd
from pprint import pprint
from openai import OpenAI
client = OpenAI()
client.api_key = os.getenv("OPENAI_API_KEY")
def chat(new_question, history):
@companje
companje / TFT show formula.ino
Created May 18, 2024 15:00
TFT show formula
#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#define YP A2 // must be an analog pin, use "An" notation!
#define XM A1 // must be an analog pin, use "An" notation!
#define YM 14 // can be a digital pin, this is A0
#define XP 17 // can be a digital pin, this is A3
// String msg = "Hello String";