Skip to content

Instantly share code, notes, and snippets.

View RobSpectre's full-sized avatar

Rob Spectre RobSpectre

View GitHub Profile
@RobSpectre
RobSpectre / wagtail.md
Created June 24, 2025 17:52
Gemini guide to integrate Oso with Wagtail

Of course! Integrating Oso Cloud with a Wagtail application is a fantastic way to handle sophisticated permissions beyond what's available out-of-the-box. Since Wagtail is built on Django, we'll be using the Python SDK and focusing on how to model Wagtail's concepts like Pages, Users, and Groups within Oso.

Let's walk through this step-by-step, following a similar path to the Oso Cloud Quickstart, but tailored specifically for your Wagtail project.

The Goal:

We'll implement a role-based access control (RBAC) system where users can be assigned "Editor" or "Viewer" roles on specific sections of your Wagtail site (i.e., on specific Page nodes and their descendants).


Phase 1: Account & Project Setup

@RobSpectre
RobSpectre / pitwall-tests.json
Last active June 14, 2025 18:57
test badge for Pitwall
{"schemaVersion": 1, "label": "tests", "message": "passing", "color": "brightgreen"}
{"schemaVersion": 1, "label": "coverage", "message": "0%", "color": "red"}
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
function isSignedIn() {
return request.auth != null;
}
function isUser(userId) {
return request.auth.uid == userId;
}
import firebase_admin
from firebase_admin import firestore, storage
from flask import abort
from google.cloud.firestore_v1.base_document import DocumentSnapshot
import app.config
firebase_app = firebase_admin.initialize_app(options={"storageBucket": app.config.FIREBASE_STORAGE_BUCKET})
bucket = storage.bucket()
db = firestore.client()
@RobSpectre
RobSpectre / zello_to_ogg.c
Created January 24, 2025 21:52
A C program that converts extracted Zello voice messages from their custom file format to Ogg Opus.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ogg/ogg.h>
#include <opus/opus.h>
#define SAMPLE_RATE_HZ 48000
#define CHANNELS 1
#define MAX_PACKET_SIZE 2048
@RobSpectre
RobSpectre / copy.js
Last active December 5, 2024 18:47
Google Tag Manager capture key commands
dataLayer.push({
'event': 'Docs Copy To Clipboard With Keyboard',
'eventCallback': function() {
document.addEventListener('copy', function(e) {
dataLayer.push({
'event': 'Docs Copy To Clipboard With Keyboard'
});
});
}
});
flowchart TD
User@{ shape: manual-input, label: "User"} -->|GET| App{Your Application}
App -->|Context + Flag Key| LDClient[LaunchDarkly SDK Client]
LDClient -->|get flag value| LDServer[LaunchDarkly Service]
LDServer -->|receive flag value| LDClient
LDClient -->|flag value| App
App -->|Delivers user experience| User
import ldclient
from ldclient.config import Config
from ldclient import Context
ldclient.set_config(Config('sdk-copy-your-sdk-key-here'))
client = ldclient.get()
if __name__ == "__main__":
alice = Context.builder('user-id-123abc1').kind('user').name('Alice').set('email', '[email protected]').build()
import ldclient
from ldclient.config import Config
from ldclient import Context
# Import your application
from yourapp import App
# Instantiate your application
app = App()