Skip to content

Instantly share code, notes, and snippets.

View stephancasas's full-sized avatar

Stephan Casas stephancasas

View GitHub Profile
@stephancasas
stephancasas / AdvancedToolbarWindow.swift
Last active April 17, 2025 03:56
A SwiftUI-compatible window for macOS with advanced toolbar configurability.
//
// AdvancedToolbarWindow.swift
//
// Created by Stephan Casas on 3/17/23.
//
import SwiftUI;
import AppKit;
class AdvancedToolbarWindow<MainContent: View, ToolbarContent: View, TitleToolbarContent: View>: NSWindow, NSToolbarDelegate {
@stephancasas
stephancasas / toggle-ventura-sidecar.jxa.js
Last active July 15, 2025 09:40
Toggle sidecar or screen mirroring from Control Center in macOS Ventura
#!/usr/bin/env osascript -l JavaScript
/**
* -----------------------------------------------------------------------------
* Activate Sidecar/Screen Mirroring from Control Center
* -----------------------------------------------------------------------------
*
* Created on February 17, 2023 by Stephan Casas
* Updated on May 18, 2023 by Stephan Casas
*
@stephancasas
stephancasas / ventura_messages.m
Created February 3, 2023 01:09
Query the attributedBody column in the updated macOS Ventura Messages database
//
// ventura_messages.m
// macOS Ventura Messages DB Query Example
//
// Created by Stephan Casas on 2/2/23.
//
#import <Foundation/Foundation.h>
@implementation NSData (NSDataExtended)
@stephancasas
stephancasas / rewire.js
Created December 31, 2022 20:41
A fault-tolerant Livewire $wire.entangle() alternative for AlpineJS
/**
* -----------------------------------------------------------------------------
* $rewire -- A Livewire $wire.entangle() alternative for AlpineJS
* -----------------------------------------------------------------------------
*
* $rewire provides the same functionality as the stock $wire Alpine magic, but
* adds consideration for implementations where Livewire may conditionally
* remove markup referencing undefined properties.
*
* It does this by using a regular expression pattern to check that the Livewire
@stephancasas
stephancasas / macos-modifier-keys-dec-map.json
Last active June 27, 2025 21:02
macOS Modifier Keys Decimal Values Map
{
"65536": [
"alphashift"
],
"131072": [
"shift"
],
"196608": [
"alphashift",
"shift"
@stephancasas
stephancasas / dterm.sh
Created November 19, 2022 16:25
Connect to an existing Docker container and start an interactive shell (terminal / tty).
dterm() {
# args as `[PROJECT_NAME] [SERVICE_NAME]` or `[CONTAINER_NAME]`
[ -z "$2" ] && CONTAINER_BASE_NAME="$1" || CONTAINER_BASE_NAME="${1}_${2}"
CONTAINER_NAME=$(docker ps --format "{{.Names}}" | grep ^${CONTAINER_BASE_NAME})
if [ $(printf "$CONTAINER_NAME" | wc -l) -gt 1 ]; then
echo "\e[1;31m[!] Multiple container names match \"$CONTAINER_BASE_NAME.\""
echo ">>> If project, add specificity as \`dockertty [PROJECT_NAME] [SERVICE_NAME]\`.\e[0m"
return
@stephancasas
stephancasas / tmux-send-keys-controls.md
Last active June 19, 2025 10:36
A list of special control sequences you can send to tmux via the send-keys command.

Tmux Send-keys Prefixed Controls

When using the tmux send-keys command, these sequences can be used to control the cursor position or perform other special operations.

This reference is based on my own observations in tmux on Alpine Linux, as I could not find an actual reference for these.

Sequence Description
C-; Send literal "C-"
C-A Move cursor to home
@stephancasas
stephancasas / losecontrol.sh
Last active October 1, 2022 00:58
losecontrol.sh — remove control characters from the logged output of a screen session
#!/bin/sh
# ---------------------------------------------------------------------------- #
# losecontrol.sh
# ---------------------------------------------------------------------------- #
#
# Author:
# Stephan Casas <[email protected]>
#
# Description:
@stephancasas
stephancasas / straycat.sh
Last active March 15, 2025 09:23
straycat.sh — a minimal HTTP server script for netcat.
#!/bin/sh
# ------------------------------------------------------------------------------
# Straycat.sh HTTP Server (straycat)
# ------------------------------------------------------------------------------
#
# Author:
# Stephan Casas <[email protected]>
#
# Description: