Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🌊

Alexander Dunkel Sieboldianus

💭
🌊
View GitHub Profile
@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
View readme.md

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
View steps.md
@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)
View 00_svg-export-bokeh.md

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 February 10, 2023 07:17
An opinionated nextcloud ignore list for developers (sync-exclude.lst)
View README.md

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 / README.md
Last active July 20, 2022 08:15 — forked from centic9/userDefineLang_Dockerfile.xml
Notepad++ syntax highlighting for Dockerfiles (Dark version)
View README.md

Notepad++ syntax highlighting for Dockerfiles (Dark version)

Store userDefineLang_DockerfileDark.xml at %AppData%\Roaming\Notepad++\userDefineLangs\userDefineLang_DockerfileDark.xml and select Language > Dockerfile in Notepad++.

This color theme is specifically compatible with VS2015-Dark-Npp Theme.

Automatically apply style

@Sieboldianus
Sieboldianus / iframe.php
Created January 31, 2022 11:56
Stackoverflow as iframe with php file_get_contents();
View iframe.php
<!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>
View main.py
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()