Skip to content

Instantly share code, notes, and snippets.

View encima's full-sized avatar
🐴
selling spare horse kidneys. PM me

Chris Gwilliams encima

🐴
selling spare horse kidneys. PM me
View GitHub Profile
@encima
encima / all_in_one.sh
Created September 24, 2026 06:03
Get all contributors for public repos in an Org (requires GH CLI)
#!/bin/bash
ORG="supabase"
OUTPUT="org_contributors.csv"
TMP_CONTRIBUTORS=$(mktemp)
TMP_MEMBERS=$(mktemp)
# Get all public repositories and aggregate contributors
gh repo list "$ORG" --public --limit 1000 --json name -q '.[].name' |
@encima
encima / switch-db-template-collation.sql
Created September 23, 2026 09:26
Collation change of a Postgres DB on Upgrade - Must be running 17 or above
UPDATE pg_database SET datistemplate = false WHERE datname = 'template0';
UPDATE pg_database SET datistemplate = false WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1
TEMPLATE template0
ENCODING 'UTF8'
LOCALE_PROVIDER builtin
BUILTIN_LOCALE 'C.UTF-8';
DROP DATABASE template0;
CREATE DATABASE template0
@encima
encima / pg2sql_exporter.py
Created July 1, 2026 07:43
postgres_exporter to sql_exporter query converter
from __future__ import annotations
import argparse
from pathlib import Path
import sys
from typing import Any
import yaml
@encima
encima / Dockerfile
Last active November 18, 2025 10:17
pg_net 0.8.0 to 0.19.5 upgrade on debian
FROM postgres:15-bookworm
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
postgresql-server-dev-15 \
libcurl4-openssl-dev \
git \
ca-certificates \
wget \
@encima
encima / conmon.sql
Last active November 17, 2025 13:42
Historical Postgresql Connection Monitoring
create schema if not exists conmon;
create table if not exists conmon.connection_activity_history (
snapshot_id bigint generated always as identity primary key,
sampled_at timestamptz not null default now(),
total_backends integer not null,
active_backends integer not null,
idle_backends integer not null,
waiting_backends integer not null,
app_connections jsonb not null,
@encima
encima / index.ts
Created June 13, 2025 07:12
Supabase User Impersonation Edge Function
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { createClient } from "jsr:@supabase/supabase-js@2";
Deno.serve(async (req)=>{
if (req.method === 'OPTIONS') {
return new Response('ok', {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, OPTIONS',
@encima
encima / mgmt-config.bash
Created March 26, 2025 08:53
Supabaase Management API to config - pulling from the Management API to match the config.toml reference
#!/bin/bash
set -e
# Default values
OUTPUT_FILE="config.toml"
# Function to display usage information
usage() {
echo "Usage: $0 --ref <project_ref> [--token <access_token>] [--output <output_file>]"
echo
@encima
encima / mgmt-config.bash
Created March 26, 2025 08:53
Supabaase Management API to config - pulling from the Management API to match the config.toml reference
#!/bin/bash
set -e
# Default values
OUTPUT_FILE="config.toml"
# Function to display usage information
usage() {
echo "Usage: $0 --ref <project_ref> [--token <access_token>] [--output <output_file>]"
echo
@encima
encima / index.ts
Created June 26, 2024 12:46
PG Faker Function - Fake data on the edge
import { HTTPException, Hono } from "https://deno.land/x/hono@v4.3.11/mod.ts";
import type { Context } from 'https://deno.land/x/hono/mod.ts';
import { faker } from "https://deno.land/x/deno_faker@v1.0.3/mod.ts";
import * as postgres from 'https://deno.land/x/postgres@v0.17.0/mod.ts'
const app = new Hono();
const dbURL = Deno.env.get('SUPABASE_DB_URL');
const pool = new postgres.Pool(dbURL, 3, true)
const schemas = {
@encima
encima / labeler.yaml
Created May 17, 2024 09:55
Auto Label Issues and PRs - Github Action
name: Auto Label PRs
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
check-external:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.is-member.outputs.result }}
steps: