Skip to content

Instantly share code, notes, and snippets.

View themerius's full-sized avatar

Sven Hodapp themerius

View GitHub Profile
@themerius
themerius / sqlalchemy_model_bigquery.py
Last active March 14, 2024 08:28
Fixing Sqlalchemy UUID mapping when using BigQuery.
# I encountered this error when using `Mapped[uuid.UUID]` in my sqlalchemy 2.0 data models in conjuntion with BigQuery:
# sqlalchemy.exc.DatabaseError: (google.cloud.bigquery.dbapi.exceptions.DatabaseError) 400 POST https://bigquery.googleapis.com/bigquery/v2... Type not found: CHAR at [3:14]
# requirements:
# pip install sqlalchemy-bigquery=1.11.0.dev2
# Here is the fix:
from operator import attrgetter
from sqlalchemy.types import TypeDecorator, String
@themerius
themerius / EPubGenerator.scala
Last active November 17, 2021 10:58
Generate a simple epub file with scala / java containing video and images
package services
import java.io._
import java.nio.charset.StandardCharsets
import java.util.zip.{ZipEntry, ZipOutputStream}
object EPubGenerator extends App {
// based on examples found here https://idpf.github.io/epub3-samples/30/samples.html
@themerius
themerius / version-detector.sh
Created August 22, 2017 09:00
Get newest version with Bash
#!/bin/bash
# Portable script (Linux, Mac/BSD) to detect the folder with the newest version.
# Assume:
# We have a folder structure like this:
#
# /path/to/my_program/my-program-0.1.0/
# /path/to/my_program/my-program-0.5.0/
# /path/to/my_program/my-program-0.10.0/
@themerius
themerius / maven-to-directory.sh
Created August 2, 2017 11:23
Download a maven artifact to directory
#!/bin/bash
# Background: This is useful to download executable JARs,
# so wie can use Artifactory+Maven like an "App Store for Java services".
# This will download the newest version,
# but you can also declare a specific version number.
VERSION="LATEST"
ARTIFACT="com.hazelcast:hazelcast-all:$VERSION:jar"
@themerius
themerius / manual-deploy-artifactory.sh
Created August 2, 2017 09:47
Manual deployment onto Artifactory using CURL
#!/bin/bash
# For example a non-Maven pipelie builds something,
# but you want that it can be used by Maven...
WORKSPACE="/path/to/workspace"
ARTIFACT="my-artifact"
ARTY="your.arty.tdl"
# Assumption that a version number is part of the artifact's name
@themerius
themerius / cronic-monitoring
Last active August 13, 2017 16:50
Poor mans service monitoring implemented with crond.
# This cron-file should be deployed to crond:
# $ crontab cronic-monitoring
# Crond will start your services and checks for example every minute, if they are alive.
# Examples:
* * * * * bash -l -c "/abs/path/to/servicename_cronic-monitoring.sh config_a /abs/path/to/servicename_home"
* * * * * bash -l -c "/abs/path/to/servicename_cronic-monitoring.sh config_b /abs/path/to/servicename_home"