Skip to content

Instantly share code, notes, and snippets.

View Sieboldianus's full-sized avatar
💭
🌊

Alexander Dunkel Sieboldianus

💭
🌊
View GitHub Profile
from fastapi import FastAPI
from pydantic import BaseModel, validator, BaseConfig
from geoalchemy2 import WKTElement
from geoalchemy2.shape import to_shape
"""Minimum working example snippet for handling lat lng coordinates and geometry types using Fastapi"""
app = FastAPI()
@Sieboldianus
Sieboldianus / iframe.php
Created January 31, 2022 11:56
Stackoverflow as iframe with php file_get_contents();
<!DOCTYPE html><html>
<?php
$url = 'https://stackoverflow.com/questions/5710867/downloading-and-unzipping-a-zip-file-without-writing-to-disk&noredirect=1';
$site = file_get_contents($url);
$site = preg_replace('#<div class="ff-sans ps-fixed z-nav-fixed ws4 sm:w-auto p32 sm:p16 bg-black-750 fc-white bar-lg b16 l16 r16 js-consent-banner">(.*?)</div>#s', ' ', $site);
$site = preg_replace('~<\s*\bscript\b[^>]*>(.*?)<\s*\/\s*script\s*>~is', ' ', $site);
echo $site
?>
</html>
@Sieboldianus
Sieboldianus / 00_svg-export-bokeh.md
Last active September 8, 2022 10:09
Setup and use svg export in bokeh/holoviews inside Docker (webdriver setup, browser installation)

Just to memorize, these are the steps to setup webdriver (chrome) and svg-export as of Bokeh 2.4.3 / Holoviews 1.14.8

This was tested in a Debian-based Docker container, but should work in most Linux distributions.

Install Selenium

Install in your conda environment:

conda install selenium webdriver-manager -c conda-forge
@Sieboldianus
Sieboldianus / readme.md
Last active May 2, 2023 06:18
Automate getting monthly PDFs from websites, protected by (simple) credentials, with Selenium and Chromedriver

I have a number of monthly manual tasks that I could not automate so far.

One of them is getting PDF from login-protected websites, saving them in specific folders with naming conventions (renaming etc.) and uploading those to my nextcloud.

The script below is for my Electricity Provider's PDFs. They are behind a simple login form (user & pw) and uploaded for the past 6 months. I always forget to check regularly enough to download all.

Two key takeaways:

  1. Use selenium/standalone-chrome Docker image
@Sieboldianus
Sieboldianus / steps.md
Created January 25, 2023 10:18
Use Windows Pageant SSH-Agent in WSL2 with socat wsl-ssh-agent-relay
@Sieboldianus
Sieboldianus / readme.md
Last active October 29, 2023 17:48
Batch convert all InDesign *.indd files to *.idml files

For backwards compatibility, I wished to batch convert all the *.indd files on my drive to *.idml.

The files are spread over my whole drive.

Here are the steps:

1. Get a list of *.idml files and paths

Use any search tool. Since Windows Search does not work on my side, I am using WSL:

@Sieboldianus
Sieboldianus / README.md
Last active January 7, 2024 13:26
Download all Features from all layers of a WFS Service and save as separate shapefile per layer, with iteration (BfN example)

Example to retrieve all WFS Features and store as shapefile with pandas and geopandas.

Setup:

conda create -n wfs_env -c conda-forge
conda activate wfs_env
conda install owslib geopandas requests

First, check capabilities in browser :

@Sieboldianus
Sieboldianus / README.md
Last active January 26, 2024 14:49
An opinionated nextcloud ignore list for developers (sync-exclude.lst)

An opinionated nextcloud ignore list for developers (sync-exclude.lst)

The latest nextcloud server versions will have ransomware detection automatically enabled, meaning that syncing common developer file types (e.g. .lock) will return errors.

Fatal webdav OCA\DAV\Connector\Sabre\Exception\Forbidden: Ransomware file detected. Prevented upload of ..py/bokeh/secrets.tar.enc because it matches extension pattern ".enc"

If you are syncing complex, nested work directories as a developer, the following

@Sieboldianus
Sieboldianus / pull_snapshots.sh
Last active January 27, 2024 10:21
Syncoid: Script to pull ZFS datasets from a file with a list of key:value, to replace non-working --recursive option in case of sendoptions=R
#!/bin/bash
################################################################################
#
# Shell script to pull zfs snapshots with syncoid using a list of key:value pairs
# Works with sendoptions=R, where syncoid's --recursive flag cannot be used
#
# IMPORTANT: Use bash, not sh! e.g.: > bash pull_snapshots.sh
#
################################################################################
@Sieboldianus
Sieboldianus / README.md
Last active February 21, 2024 12:59
Create New Folder and Create New File AutoHotKey Scripts

Create New Folder and Create New File AutoHotKey Script

Tested for: Win7, Win10, Win11

These two scripts are slightly modified from [1][1]:

  • Alt+N will create a filename, with default name notes.md
  • Alt+F will create a folder, with default name of the current date in format YYYY-MM-DD

Note: