Skip to content

Instantly share code, notes, and snippets.

View companje's full-sized avatar

Rick Companje companje

View GitHub Profile
@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";
@companje
companje / lerpColor blue yellow.pde
Last active May 17, 2024 22:20
Lerp / Blend color - blue+yellow and cyan+yellow
import processing.serial.*;
int h=40;
Serial port;
void setup() {
size(320, 320);
background(0);
port = new Serial(this, "/dev/cu.usbmodem21401", 9600);
}
@companje
companje / 0.... Control Excel 97 by Joystick and other sensors (work in progress).txt
Last active May 14, 2024 22:08
Control Excel 97 by Joystick and other sensors (work in progress).
.
@companje
companje / Orientate circle on sphere.pde
Created March 25, 2024 01:03
Orientate circle on sphere
//...
PVector axis = PVector.cross(lens, new PVector(0, 0, -1), null);
float angle = PVector.angleBetween(lens, new PVector(0, 0, 1));
pushMatrix();
rotate(angle, axis.x, axis.y, axis.z);
translate(0, 0, height/2-3);
noFill();
stroke(0);
strokeWeight(5);
hint(DISABLE_DEPTH_TEST);