Skip to content

Instantly share code, notes, and snippets.

View moosetraveller's full-sized avatar

Thomas Zuberbühler moosetraveller

View GitHub Profile
@moosetraveller
moosetraveller / example.html
Last active May 18, 2023 19:00
Inject a HTML file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Template Test</title>
</head>
<body>
@moosetraveller
moosetraveller / embedded-python-win.md
Last active January 9, 2023 19:01
Prepare Embedded Python with GIS Packages for Windows

Prepare Embedded Python with GIS Packages for Windows

Download Python

Get PIP for Python

  • download get-pip.py from here
@moosetraveller
moosetraveller / open-url.md
Created August 25, 2022 17:23
How to open file from URL with Python

How to open a file from URL with Python

Using urllib.request

# !pip install cairosvg matplotlib pillow

import io
from urllib.request import Request, urlopen
import xml.etree.ElementTree as ET
@moosetraveller
moosetraveller / flask-sqlalchemy-sqlite.md
Last active September 4, 2022 21:45
Load SQLite Extension with SQLAlchemy (in Flask)

Load SQLite Extension with SQLAlchemy (in Flask)

Files

app/db.py

from flask_sqlalchemy import SQLAlchemy

from sqlalchemy import event
@moosetraveller
moosetraveller / upload-file.md
Created August 17, 2022 15:01
Upload a File with Fetch API

Upload a File with Fetch API

async function upload() {

    const input = document.querySelector('input[type="file"]');

    const data = new FormData();
    data.append("file", input.files[0]);
@moosetraveller
moosetraveller / install-pyenv.md
Last active September 1, 2022 13:27
Install Python with PyEnv

Install Python with PyEnv

  1. Install PyEnv (see also here: https://github.com/pyenv/pyenv-installer)
    • Requires GIT
    • Install with curl https://pyenv.run | bash
  2. Add following lines to vi ~/.bashrc:
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
@moosetraveller
moosetraveller / flask-celery.md
Last active August 17, 2022 14:33
Flask with Celery

Flask with Celery

Files

tasks/long_running.py

from app import celery

__all__ = ["execute_print_job"]
@moosetraveller
moosetraveller / arcgis-py-install-fails.md
Last active July 19, 2022 19:39
ArcGIS API for Python installation fails

If you receive the error shown below (or similar) when installing the arcgis package with pip, then you need to install the system component libkrb5-dev:

  • Run sudo apt install libkrb5-dev
  • Rerun pip install arcgis
Collecting gssapi
  Using cached gssapi-1.7.3.tar.gz (1.3 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
This gist I write, because I couldn't find step by step instructions
how to install and start postgresql locally and not globally in the
operating system (which would require sudo).
I hope, this will help especially people new to postgresql!
####################################
# create conda environment
####################################
@moosetraveller
moosetraveller / date_time_widget_example.py
Created June 8, 2022 02:48
Create DateTime widget for QGIS Processing Tool
from qgis.PyQt.QtCore import (
QCoreApplication,
QDateTime,
)
from processing.gui.wrappers import WidgetWrapper
from qgis.gui import QgsDateTimeEdit
from qgis.core import (
Qgis,