Skip to content

Instantly share code, notes, and snippets.

View iccir's full-sized avatar

Ricci Adams iccir

View GitHub Profile
@iccir
iccir / DebugFileIcon.py
Created December 10, 2025 03:38
Sublime Text command to debug blank/wrong file icons
# Given a file extension, displays information about the assigned file icon
#
# Usage:
#
# 1) Open a window in Sublime Text
# 2) View -> Show Console
# 3) Type in the following (with your extension instead of "h"):
# window.run_command("debug_file_icon, { "extension": "h" })
#
@iccir
iccir / FixedSlurpFindString.py
Last active December 8, 2025 16:14
Works around Sublime Text #6815 by manually sending selection to AppKit.
# Attempts to work around Issue #6815 by manually sending
# the selected text to the macOS Find Pasteboard
#
# https://github.com/sublimehq/sublime_text/issues/6815
from __future__ import annotations
import ctypes
import ctypes.util
import sublime
@iccir
iccir / example.service
Created September 6, 2025 17:12
systemd config for nodejs webapp
#
# Run a nodejs webapp in a systemd sandbox
#
# - Needs network I/O to localhost
# - Needs the ability to send mail via sendmail
#
[Unit]
Description=Example Service
After=network.target
@iccir
iccir / make_local_certs.sh
Last active February 9, 2025 18:58
Generate certificates for .local domains
#!/bin/sh
#
# Generate self-signed certificates for local development
# /www/keys/LocalRootCA.crt will need to be imported into Keychain Access
# and set to "Always Trust"
#
BASE_PATH="/www/keys"
ROOT_PATH="$BASE_PATH/LocalRootCA"
@iccir
iccir / core_audio_tap_example.m
Last active October 24, 2025 01:24 — forked from directmusic/core_audio_tap_example.m
This is a modification of Joseph Lyncheski's original. It shows how to set up a CoreAudio tap to apply an effect (in this case, a low-pass filter) to all audio. **Note: This is not production-quality code and makes several assumptions. This will likely explode on certain configurations.**
// This is a quick example of how to use the CoreAudio API and the new Tapping
// API to create a tap on the default audio device. You need macOS 14.2 or
// later.
// Build command:
// clang -framework Foundation -framework CoreAudio main.m -o tapping
// License: You're welcome to do whatever you want with this code. If you do
// something cool please tell me though. I would love to hear about it!
@iccir
iccir / SimStatusBar.sh
Last active June 2, 2025 12:20
iOS Simulator Status Bars
# iPhone with home button
xcrun simctl status_bar booted clear
xcrun simctl status_bar booted override \
--time "9:41 AM" \
--wifiBars 3 --cellularBars 4 --operatorName ""
xcrun simctl spawn booted defaults write com.apple.springboard SBShowBatteryPercentage 1
# iPhone X
xcrun simctl status_bar booted clear
xcrun simctl status_bar booted override --time "9:41" --wifiBars 3 --cellularBars 4
@iccir
iccir / PiRoomCorrection.md
Last active February 24, 2020 04:31
Raspberry Pi for Room Correction

Prepare The Device

  1. Download Ubuntu 18.04 LTS
  2. Download Balena Etcher
  3. Launch Etcher and burn image to SD card.
  4. After burning, remove and reinsert the SD card so macOS mounts it. A system-boot partition will appear.
  5. In Terminal: touch /Volumes/system-boot/ssh to enable SSH access.
  6. Safely eject the volume, remove the SD card, insert into Raspberry Pi.
  7. Connect Raspberry Pi to power and ethernet.
@iccir
iccir / gist:2363d00cadac3eb6c26aa8762e718c09
Last active January 7, 2020 08:49
Embrace's code for handling drops from Catalina's Music app, due to Apple not following the API contract for file promises. You will need to register for the kPasteboardTypeFileURLPromise drag type.
- (NSArray<NSURL *> *) parsePasteboard:(NSPasteboard *)pasteboard
{
NSMutableDictionary *trackIDToMetadataMap = [NSMutableDictionary dictionary];
NSMutableArray *orderedTrackIDs = [NSMutableArray array];
NSMutableArray *metadataFileURLs = [NSMutableArray array];
NSMutableArray *otherFileURLs = [NSMutableArray array];
auto parsePlaylist = ^(NSDictionary *playlist) {
if (![playlist isKindOfClass:[NSDictionary class]]) {
@iccir
iccir / openScreenRecordingPreferences.m
Created October 13, 2019 09:21
Open "Screen Recording" preferences on macOS Catalina
static void sOpenScreenRecordingPreferences()
{
CFDataRef passThruData = CFBridgingRetain([@"Privacy_ScreenCapture" dataUsingEncoding:NSUTF8StringEncoding]);
CFArrayRef itemURLs = CFBridgingRetain(@[ [NSURL fileURLWithPath:@"/System/Library/PreferencePanes/Security.prefPane"] ]);
OSStatus err = noErr;
AEDesc passThruDesc = {0};
BOOL needsDispose = NO;
@iccir
iccir / darkmode.m
Last active May 6, 2021 00:47
iOS Dark Mode Toggle
/*
During Dark Mode migration for macOS, I found it helpful to have a global hotkey
which toggled between Light/Dark Mode.
This hack attempts to do something similar for iOS.
1) Add your main window in -applicationDidFinishLaunching:
2) Triple tap the window (I tend to do this near the title bar) to flip between light and dark.
*/