Skip to content

Instantly share code, notes, and snippets.

View ThingEngineer's full-sized avatar
🎯
Focusing

Josh Campbell ThingEngineer

🎯
Focusing
View GitHub Profile
CREATE OR REPLACE FUNCTION v_knight(
    piece_id VARCHAR,          -- ID of the piece being moved
    target_pos VARCHAR,        -- Target position in chess notation
    board_state JSONB          -- JSON containing all pieces and their positions
)
RETURNS TABLE (
    is_valid BOOLEAN,
    message VARCHAR
) AS $$
@ThingEngineer
ThingEngineer / Dynamic Multi-Tenant RBAC with Route Authorization.sql
Last active February 15, 2025 01:57
Dynamic multi-tenant SQL-based RBAC with JWT enhancement, route authorization, and permission management using Supabase.
-- Role-Based Access Control (RBAC)
-- With live propagation of roles to JWT token in a multi-tenant application using Supabase refreshSession and custom_access_token_hook
-- A method of restricting table and route access to authorized users based on their role or permission level.
-- This SQL implements a dynamic, multi-tenant role-based access control (RBAC) system with route authorization. It includes:
-- A custom access token hook that enriches JWT claims with role and company data.
-- Functions to authorize actions, check route access, and retrieve authorized routes based on user roles.
@ThingEngineer
ThingEngineer / Python Virtual Environment Notes.md
Created January 24, 2025 20:25
Python Virtual Environment Notes

Virtual Environments (bash) A virtual environment is an isolated Python environment that allows you to install packages without affecting other Python projects or your system's Python installation. It also ensures you are working in a clean slate environment and enables reproducibility through dependency tracking.

Create:

  • mdir my_project
  • python3 -m venv my_project

Use:

  • source my_project/bin/activate
@ThingEngineer
ThingEngineer / README.md
Created March 7, 2024 17:42
SvelteKit Minimal PWA Install Button and Service Worker Auto Update Prompt

SvelteKit Minimal PWA Install Button and Service Worker Auto Update Prompt

How to use

Add this to your root +layout.svelte in your already working PWA

<script>
	import { beforeNavigate } from '$app/navigation';
	import { updated } from '$app/stores';
	import { onMount } from 'svelte';
@ThingEngineer
ThingEngineer / README.md
Last active March 7, 2024 17:31
SvelteKit PWA Install Prompt Browser Test/Demo

SvelteKit PWA Install Prompt Browser Test/Demo

How to use

Add this to your root +layout.svelte in your already working PWA

<script>
let deferredPrompt;
	let installButtonVisible = false;
	let output = '';

	onMount(() => {
@ThingEngineer
ThingEngineer / goes16-rtlsdr.md
Created May 28, 2020 15:59 — forked from lxe/goes16-rtlsdr.md
Receive GOES-16 and GOES-17 Images with a Raspberry Pi and RTL-SDR dongle

Keybase proof

I hereby claim:

  • I am thingengineer on github.
  • I am joshcampbell (https://keybase.io/joshcampbell) on keybase.
  • I have a public key ASBGn17Q6cYHyA0N5tAK1OOVfN5SmHZVUCmeHBI33g7rhwo

To claim this, I am signing this object: