Skip to content

Instantly share code, notes, and snippets.

View brennanMKE's full-sized avatar

Brennan Stehling brennanMKE

View GitHub Profile
@brennanMKE
brennanMKE / DENIED-PINS.MD
Last active January 13, 2025 07:22
Schlage Smart WiFi Deadbolt: Access Control

To ensure security, you should disallow the use of common and easily guessable 4-digit PINs. Here’s a list of such PINs to block:

  1. Sequential Numbers:
    • 1234
    • 2345
    • 3456
    • 4567
    • 5678
    • 6789
  • 7890
@brennanMKE
brennanMKE / README.md
Created December 19, 2024 19:41
Web Server Mapping Bluesky Profiles

Web Server Mapping Bluesky Profiles

With this solution, there is no CGI programming. One innefficency of CGI programming is that every request spawns another process which can be costly when there are many requests. Instead the work with this solution is done up front by generating the output from the JSON files to static files. Incoming requests are handled by rewrite rules supported by the web server which are handled in process and very quickly.

Changes can be made to the JSON files and re-run the generation script which will create output to a temporary directory and then rsync the changes to the directory used by the rewrite rules. This way removed profiles will also be removed from the web server.

(from ChatGPT)

Script: generate_profile_files.sh

@brennanMKE
brennanMKE / README.md
Last active December 14, 2024 22:19
Bluesky Accounts Server on AWS

Bluesky Accounts Server on AWS

ATProto Well-Known Routes

On Bluesky and other ATProto-based platforms, users can associate their accounts with their own domain names instead of relying on service-owned subdomains. To do this, you need to prove that you control the domain by publishing a special file at a specific, “well-known” location or by adding a DNS record. Once verified, your account’s handle can become something like @username.example.com instead of @username.bsky.social.

For organizations that want to create multiple user accounts, using a separate hostname for each user makes management easier. By setting up a wildcard DNS record (e.g., *.example.com), you can quickly create new hostnames for any user without having to run separate websites or add individual DNS entries. Each of these hostnames can return a unique DID (Decentralized Identifier) to ATProto services through a simple, automated process.

In the following example, DID values are stored as simple JSON files. A small CGI scri

@brennanMKE
brennanMKE / README.md
Created December 13, 2024 20:22
Matter and Thread with ESP32

From ChatGPT:

Below is a step-by-step guide and example setup showing how you might structure an ESP32-based Matter + Thread project using the Arduino framework within VS Code and PlatformIO. This is a conceptual walkthrough intended for beginners who are totally new to Matter and Thread. Please note that Matter and Thread support for Arduino on ESP32 is still quite limited and experimental. The code and steps below are for illustrative purposes, showing how you would approach organizing such a project. Actual implementation may require additional tooling, libraries, and following the evolving Matter ecosystem.


Prerequisites

  1. Hardware:
  • An ESP32 development board (e.g., ESP32-DevKitC).
@brennanMKE
brennanMKE / README.md
Created November 28, 2024 04:00
Task Queue mimicks NSOperationQueue

TaskQueue

This code supports running a sequence of tasks with serial behavior or concurrently with max concurrent tasks. The tasks which are queued can even be constrained to a global actor like @MainActor or a custom global actor.

This API mimics NSOperationQueue which was available prior to Dispatch. It supports max concurrent tasks and other features. One feature is barrier tasks. Normally tasks are allowed to run concurrently. When a task is a barrier it will be run serially. All pending tasks will be allowed to complete and then a the lone barrier task will be run. Then other tasks can run as before. This is a useful behavior to use when multiple tasks do work and a barrier task can run after them to gather the outputs before running another set of tasks to do more processing.

@brennanMKE
brennanMKE / README.md
Created November 28, 2024 00:08
AT Protocol in Swift

To get started with implementing your custom feed and moderation services using the ATProtoKit Swift package, follow these steps:

  1. Clone the Repository

First, clone the ATProtoKit repository to review the examples and understand the package:

git clone https://github.com/MasterJ93/ATProtoKit.git
cd ATProtoKit
@brennanMKE
brennanMKE / tinyzip.sh
Created November 28, 2024 00:08
Tiny Zip
#!/bin/bash
usage() {
echo "Usage: $0 <folder_name>"
echo "Provide the name of an existing directory to be zipped."
}
run() {
local DIRECTORY_NAME="$1"
@brennanMKE
brennanMKE / Sync.swift
Last active November 28, 2024 00:14
Sync
private let lock = NSRecursiveLock() // Lock for thread-safe access
func sync<T>(@_implicitSelfCapture operation: @escaping @Sendable () throws -> T) rethrows -> T {
lock.lock()
defer { lock.unlock() }
return try operation()
}
func doWork() {
sync {
@brennanMKE
brennanMKE / ThrowingTaskGroup.swift
Created November 7, 2024 21:26
Useful extension for ThrowingTaskGroup
extension ThrowingTaskGroup {
func reduceAll() async throws -> [Element] {
try await reduce(into: []) { $0.append($1) }
}
}
@brennanMKE
brennanMKE / README.md
Created October 25, 2024 19:33
Debugging ESP32-C3 with PlatformIO and VS Code on macOS

Debugging ESP32-C3 with PlatformIO and VS Code on macOS

TL;DR

Add the following to platformio.ini:

debug_tool = esp-builtin