Skip to content

Instantly share code, notes, and snippets.

View brennanMKE's full-sized avatar

Brennan Stehling brennanMKE

View GitHub Profile
@brennanMKE
brennanMKE / README.md
Last active February 26, 2025 18:10
Essential Git Aliases

Essential Git Aliases

The following Git aliases are very helpful for my usual workflow.

[alias]
	cb = switch -c
	sw = switch
	wip = commit -m wip
	rr = pull --rebase origin
@brennanMKE
brennanMKE / QED.md
Created February 14, 2025 23:48
QED

The tradition of writing Q.E.D. ("quod erat demonstrandum") at the end of a mathematical proof is the culmination of a long intellectual lineage that began with Pythagoras, evolved through Plato, Aristotle, Euclid, and Archimedes, and ultimately shaped the foundations of logical demonstration in mathematics. Each thinker built upon the ideas of their predecessors, refining the principles of proof, logic, and rigor that remain central to mathematics today.

Pythagoras (c. 570–495 BCE) – Mathematics as Abstract Truth

Pythagoras and his followers were among the first to view mathematics as a philosophical pursuit, believing that numbers and geometric relationships governed the universe. They sought logical justification for mathematical truths, leading to the earliest systematic proofs in history. The Pythagorean Theorem exemplifies their approach, demonstrating how mathematical relationships could be established through reasoning rather than empirical observation. However

@brennanMKE
brennanMKE / README.md
Last active February 6, 2025 19:31
Actor isolation in unit tests

Actor isolation in unit tests

Automated tests with actors can result in using await across many lines which is a lot of lock/unlock cycles which can have some unwanted side effects. In the very least it can just make your unit tests run more slowly. I wanted to see how I could set up my tests to evaluation expectations within the isolated actor scope. I found I could use an isolated parameter with a block to do it. See the code snippet for the function below.

private func run(_ actorInstance: <#actor type#>,
                 block: @Sendable (isolated <#actor type#>) async -> Void) async {
    await block(actorInstance)
}
@brennanMKE
brennanMKE / README.md
Created January 24, 2025 18:26
Open Source alternatives to Buffer

Open Source alternatives to Buffer

Open Source, self-hosted alternatives to Buffer that allow you to manage and schedule posts for multiple social media platforms. Here are some of the most popular options:


  • Description: An open-source social media management platform that supports scheduling, posting, and analytics for multiple social platforms.
  • Supported Platforms: Facebook, Twitter, LinkedIn, Instagram, and YouTube.
  • Features:
@brennanMKE
brennanMKE / README.md
Created January 23, 2025 00:16
Hosting a static website which is generated with Jekyll and managed with Netlify CMS

Step-by-Step Guide to Create a Jekyll Static Website with Self-Hosted Netlify CMS

1. Prerequisites

Ensure you have the following tools and accounts ready:

  • A GitHub account and a new repository created for your website.
  • Jekyll installed on your local machine.
  • Node.js and npm installed.
  • A server to host your static website and CMS (e.g., AWS, DigitalOcean, or another hosting provider).

@brennanMKE
brennanMKE / DENIED-PINS.MD
Last active May 28, 2025 20:35
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.