Skip to content

Instantly share code, notes, and snippets.

View FabianZweckinger's full-sized avatar

Fabian Zweckinger FabianZweckinger

View GitHub Profile
@FabianZweckinger
FabianZweckinger / ecqb-ppl-json-parser.py
Last active July 14, 2023 12:40
Python script for parsing ECQB-PPL questions into a json file and extracting images.
# Add question files from a provider like Aeroclub (https://aeroclub.at/de/behoerde/download)
import os
from PyPDF2 import PdfReader
import re
import json
# Make sure the spl-ecqb-ppl files are placed in /sourcefiles directory.
os.makedirs("images", exist_ok=True)
@FabianZweckinger
FabianZweckinger / color-quantization-cv2.py
Last active June 3, 2023 19:25
Python color quantization / reduction to a custom degree using CV2 library. The color palette gets chosen automatically, by the most used colors.
# Credits to Stackoverflow user u1234x1234
# Source: https://stackoverflow.com/questions/73666119/open-cv-python-quantize-to-a-given-color-palette
# The example was changed to automatically pick up the primary colors
import cv2
import numpy as np
image_path = 'input.png'
image_output_path = 'output.png'
quantize_count = 16 # How many colors will be left
@FabianZweckinger
FabianZweckinger / request-data-from-open-meteo-api.py
Last active April 14, 2023 15:29
Python request hourly temperature and humidity data at some coordinates using Open Meteo's Api (https://api.open-meteo.com/v1/forecast) and displaying with matplotlib
import requests
import matplotlib.pyplot as plt
import datetime
latitude = 48.3
longitude = 13.3
# Get data from api.open-meteo.com
response = requests.get('https://api.open-meteo.com/v1/forecast'
'?latitude=' + str(latitude) + '&longitude=' + str(longitude) + '&'
@FabianZweckinger
FabianZweckinger / receive-call-list-from-fritzbox.py
Last active April 14, 2023 15:29
Use python to receive call list from a FritzBox, including the caller, date, time, duration and type (missed, answered, outgoing)
import requests
from fritzconnection import FritzConnection
import xml.etree.ElementTree as Et
CALL_LOG = 5
# Definition of call's type value:
# src: https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/x_contactSCPD.pdf
# 1 incoming Call answered by phone or answering machine.
# 2 missed Incoming call was not answered by internal phone or answering machine.