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
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  
@brennanMKE
brennanMKE / README.md
Created October 10, 2024 17:15
macOS Command Line Cheat Sheet

Command Line Tips for macOS

Command-line hotkeys for macOS:

Action Hotkey
Autocomplete command Tab
Move cursor left/right by character Control + B / Control + F
Move cursor left/right by word Option + / Option +
Move to beginning of line Control + A
@brennanMKE
brennanMKE / README.md
Created July 19, 2024 18:52
Passing WiFi credentials over Bluetooth

Passing WiFi credentials over Bluetooth

The following prompt was sent to ChatGPT.

Please help me with networking using an ESP32. I use PlatformIO in VS Code for my IDE and I'd like to give my program WiFi credentials but not include the password in source control. What I'd like to consider doing is leveraging BLE on the device so that I can run a program on my Mac which would scan for BLE devices which need WiFi credentials and share with them. I'd want to write this program in Swift with Xcode on macOS. Can you help me with how to get my ESP32 to use BLE to be discoverable when so it can get WiFi credentials and also the command-line app built in Swift?

Sure, let's break this down into two main parts:

  1. Configuring the ESP32 to use BLE for receiving WiFi credentials.
@brennanMKE
brennanMKE / README.md
Last active April 20, 2024 23:07
Killing Arduino

Killing Arduino

The Arduino IDE has had a bug which causes the entire screen to go blank and become unusable. The following issues are related to this problem. It does not appear to be closed, but the upstream bug may have been fixed indirectly.

  • [arduino-ide#2297]
  • [arduino-ide#2148]

But if this bug is not fix, you may need to recover from the blank screen. It appears it requires killing all Arduino processes since there are some background processes which support the app. You can start by getting the process id from Activity Monitor. Filter to "Arduino" and press cmd-i to get the info. Take id and run this command with it. It is in parenthese with Process Group.

@brennanMKE
brennanMKE / README.md
Last active April 5, 2024 20:51
Jitsi Meet with a headless Raspberry Pi

Jitsi Meet with a headless Raspberry Pi

To set up a headless Raspberry Pi to connect to a Jitsi Meet server using SIP and WebRTC, you'll need the following:

  1. SIP Gateway: Set up a SIP gateway for your Jitsi Meet server. Jitsi provides a component called Jigasi for this purpose. Jigasi acts as a gateway between SIP and the Jitsi Videobridge.

  2. SIP Client: Install a command-line SIP client on the Raspberry Pi. Examples include Linphone or PJSUA from the PJSIP project.

@brennanMKE
brennanMKE / README.md
Created March 27, 2024 18:04
Inventors

Electronics Inventors

  • Hedy Lamarr - Known for her career in Hollywood, Lamarr was also a talented inventor. She co-invented an early version of frequency-hopping spread spectrum communication, a technology that laid the foundation for modern Wi-Fi and Bluetooth.
  • Ada Lovelace - Often regarded as the first computer programmer, she worked on Charles Babbage's early mechanical general-purpose computer, the Analytical Engine. Her notes on the engine include what is now recognized as the first algorithm intended to be processed by a machine.
  • Grace Hopper - A rear admiral in the U.S. Navy, she was a pioneer in computer programming and was one of the first programmers of the Harvard Mark I computer. She also developed the first compiler for a computer programming language and conceptualized the idea of machine-independent programming languages, which led to the development of COBOL.
  • Edith Clarke - The first woman to earn an electrical engineering degree from MIT, Clarke invented a graphical calculator that g