Skip to content

Instantly share code, notes, and snippets.

View sebastianrothbucher's full-sized avatar

Sebastian Rothbucher sebastianrothbucher

View GitHub Profile
@sebastianrothbucher
sebastianrothbucher / pg4all.txt
Last active August 17, 2025 18:37
PG extensions - PG 4 all!
https://github.com/pgaudit/pgaudit
https://github.com/citusdata/pg_cron
https://github.com/pgvector/pgvector
https://github.com/pgmq/pgmq
https://github.com/Olshansk/postgres_for_everything
@sebastianrothbucher
sebastianrothbucher / content.xml
Last active August 9, 2025 13:25
Libreoffice odt is a ZIP - i.e. one can read forms - see form fields: content is right there. Better than manual (and better than editing custom doc props); can e.g. create an automator on Mac to xtract. Can also write-protect all but form in doc proprties. Also saves money vis-a-vis dumping it all into ChatGPT/Claude in order to get a table
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart
@sebastianrothbucher
sebastianrothbucher / cell.py
Last active August 19, 2025 11:23
Jupyter HTML and several displays - just store for once
import pandas as pd
from IPython.core.display import HTML
# display several
display("one")
display(pd.DataFrame({"a": [1, 2]}))
print("two-a")
display(HTML('<em style="color: hotpink">two-b</em><a href="https://bla">Link gets rendered in PDF</a>'))
display("two-c")
@sebastianrothbucher
sebastianrothbucher / pg-insert-missing.sql
Last active January 18, 2025 18:07
Postgres - insert missing and ignore dups -
CREATE TABLE public.test (
id int4 NOT NULL,
"text" text NULL,
CONSTRAINT test_pkey PRIMARY KEY (id)
);
insert into test (id, text) values (1, 'hey'), (2, 'ho') on conflict do nothing;
insert into test (id, text) values (2, 'hoo'), (3, 'whatever') on conflict do nothing;
-- result: 1/hey, 2/ho, 3/whatever inserted - perfect: minimum # statements, exactly what's wanted: just fill in missing
@sebastianrothbucher
sebastianrothbucher / combine.tex
Last active August 19, 2025 11:24
All PDF manipulations - nice and open src (pypdf would be an alternative - see below)
\documentclass{article}
\usepackage{pdfpages}
\usepackage{background}
\backgroundsetup{scale = 1, angle = 0, opacity = 1,
contents = {\includegraphics[width = \paperwidth,
height = \paperheight, keepaspectratio]
{testbriefkopf.pdf}}}
% for different, we can have two steps: first background, then merge
\begin{document}
\includepdf[pages=-]{dinbrief2.pdf}
@sebastianrothbucher
sebastianrothbucher / flow.json
Created August 3, 2024 18:01
Simulating a sine curve and sudden drop via Node-Red
[
{
"id": "91450f41b1eae9c6",
"type": "inject",
"z": "426169ba36026cef",
"name": "on",
"props": [
{
"p": "payload"
},
@sebastianrothbucher
sebastianrothbucher / gql-test.ts
Last active July 21, 2024 10:18
Base Apollo server (including subscriptions - can leave out ws part) - round trip
import {ApolloServer} from '@apollo/server';
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
import {expressMiddleware} from '@apollo/server/express4';
import {makeExecutableSchema} from '@graphql-tools/schema';
import express from 'express';
import cors from 'cors';
import morgan from 'morgan';
import fs from 'fs';
import {createServer} from 'http';
import { WebSocketServer } from 'ws';
@sebastianrothbucher
sebastianrothbucher / automator-shell.sh
Last active January 19, 2025 16:28
img2txt - clipboard image to clipboard text (per se: on Mac)
#!/bin/zsh
/opt/homebrew/bin/python3 -c 'import pytesseract; from PIL import Image, ImageGrab; im = ImageGrab.grabclipboard(); pytesseract.pytesseract.tesseract_cmd = "/opt/homebrew/bin/tesseract"; print(pytesseract.image_to_string(im))' | pbcopy # python3.12 for specific python
# done
@sebastianrothbucher
sebastianrothbucher / shell-helper.inc
Created May 31, 2024 14:38
STS assume role and export creds - use via . shell-helper.inc in bash
function assumeRoleAndExport {
local STS_RES=$(aws sts assume-role --role-arn $1 --role-session-name "whatever-session-$(uuidgen)")
export AWS_ACCESS_KEY_ID=$(echo $STS_RES | jq -r .Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $STS_RES | jq -r .Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $STS_RES | jq -r .Credentials.SessionToken)
}
@sebastianrothbucher
sebastianrothbucher / node-red-flows.json
Last active May 30, 2024 18:51
IoTcore simple policy and node-red flow
[
{
"id": "426169ba36026cef",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{