Skip to content

Instantly share code, notes, and snippets.

View stefan-girlich's full-sized avatar

Stefan Girlich stefan-girlich

View GitHub Profile
@stefan-girlich
stefan-girlich / supabase_fixes.ts
Created February 11, 2025 10:04
Workaround for faulty Supabase query data types, i.e. when using computed relationships
/**
* Fixes a single Supabase query response by replacing a specific field with a given type.
* Useful for overriding false-negative errors in Supabase response types for computed relationships.
*
* @see https://github.com/supabase/supabase-js/issues/1364
* @template T - the original type to modify, or null
* @template K - key of the field to replace in T
* @template R - type to replace the field with
*
* @example
@stefan-girlich
stefan-girlich / register_supabase_function_hook.sql
Created April 15, 2024 15:25
Register Supabase function hook with secret management
-- set your base URL and service role key - you need to do this once per environment
select
vault.create_secret (
'<your-key-here>',
'service_role_key',
'Supabase service_role key'
);
select
vault.create_secret (
@stefan-girlich
stefan-girlich / env.ts
Last active October 11, 2024 20:20
use Envalid to validate and expose Next.js client-side and server-side variables
import { cleanEnv, Spec, str, ValidatorSpec } from 'envalid'
// https://github.com/af/envalid
/**
* This module is the single source of truth for application environment configuration.
* When imported as a TypeScript module, it provides runtime access to validated environment variables.
* When executed as a script, it may cover the following use cases:
* - validate current environment
* - load current environment beforehand (when CLI flag --force-load-env is used)
@stefan-girlich
stefan-girlich / git-fullclean
Last active March 7, 2018 16:08
Cleans up your Git working directory, e. g. after completing a merge request
#!/bin/sh
# Save file in executable PATH, e. g. /usr/bin
# Usage: "git fullclean"
git checkout develop
git pull --rebase
git fetch --prune
BRANCHES_TO_KEEP_REGEX="(^\*|master|develop)"
@stefan-girlich
stefan-girlich / simple_ui_runner_demo.js
Last active February 5, 2016 17:04
Demo showing how to sequentially trigger UI actions to put a web application in a desired debug state; requires jQuery;
/** Demo showing how to sequentially trigger UI actions to put the a web application in a desired debug state
* - requires jQuery
* - run code when basic UI is ready, e. g. 'domready' callback or Angular controller function
* - events of indeterminable duration (e. g. asynchronous loading) are not respected ; tweak interval to suit your needs
*/
var ACTION_INTERVAL = 400; // ms
var actions = [
function enterSearchTerm() {
@stefan-girlich
stefan-girlich / rgb_tinter.py
Last active August 29, 2015 14:23
Takes a list of RGB colors as hex strings and applies the first color's hue as a tint to every other color while preserving saturation and value.
#!/usr/bin/env python3
# Takes a list of (A)RGB colors as hex strings and
# applies the first color's hue value as a tint to
# every other color while preserving saturation, value and alpha.
# Supported hex formats: RGB, ARGB
# usage: {command} {tint reference color} {first color to tint} [{more colors to tint} ...]
# example usage: rgb_tinter.py "#ff00ff" "#123456" "#abcdef" "#001122"
@stefan-girlich
stefan-girlich / fetch_from_cam.py
Last active August 29, 2015 14:20
Provides a simple CLI wizard for copying images and videos from a mounted camera and sorting them into timestamped folders.
#!/usr/bin/env python3
import os.path
import time
import datetime
import sys
import shutil
from os import listdir, mkdir
from os.path import isfile, join, basename
@stefan-girlich
stefan-girlich / deobfuscate_android_stacktrace.sh
Created April 30, 2015 09:15
Grabs an ProGuard-obfuscated Android stack trace from the OSX pasteboard, deobfuscates it using the given mapping.txt and writes the result back to the pasteboard.
#!/bin/bash
# Grabs an ProGuard-obfuscated Android stack trace from the OSX pasteboard, deobfuscates it using the given mapping.txt and writes the result back to the pasteboard.
RETRACE_BIN="retrace.sh"
MAPPING_FILE=$1
TMP_FILE="/tmp/"$(basename $0)"_tmp_outfile.txt"
if [ -z "$MAPPING_FILE" ]; then
echo "Mapping file is not given."
@stefan-girlich
stefan-girlich / androiddeviceinfo.sh
Last active October 12, 2015 07:50
Obtains basic Android device information for debugging and reporting purposes
#!/bin/bash
# Obtains basic Android device information for debugging and reporting purposes and prints it to stdout.
# * adb needs to be installed
# * exactly one device needs to be connected
LAST_BRACKET_REGEX="\ \[(.*)\]"
declare -a PROPS_KEYS=("ro.build.version.release" "ro.product.manufacturer" "ro.product.model" "ro.product.locale.language" "ro.product.locale.region" "gsm.sim.state")
@stefan-girlich
stefan-girlich / node_sanft_und_sorgfaeltig_downloader.js
Last active August 29, 2015 14:19
Crawls the official "Sanft & Sorgfältig" website and saves the available MP3 download URLs as a JSON file list with meta data and plain text URL list
var Crawler = require('crawler');
var url = require('url');
var fs = require('fs');
var NUM_PAGES = 10;
var OUTPUT_JSON_FILENAME = 'file_index.json';
var OUTPUT_TXT_FILENAME = 'file_index.txt';