Skip to content

Instantly share code, notes, and snippets.

View emorydunn's full-sized avatar

Emory Dunn emorydunn

View GitHub Profile
@brentsimmons
brentsimmons / NSMenuItem+RSCore.swift
Created January 6, 2026 04:11
Disable all menu item images in a Mac app.
//
// NSMenuItem+RSCore.swift
// RSCore
//
// Created by Brent Simmons on 1/5/26.
//
#if os(macOS)
import AppKit
import ObjectiveC
@chockenberry
chockenberry / finder_icons.sh
Created March 16, 2023 20:00
Script to toggle Finder icons
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
osascript -e 'tell application "Finder" to quit'
defaults write com.apple.finder CreateDesktop false
open -a Finder
@xdesro
xdesro / killport.sh
Last active January 7, 2026 09:31
Kill processes at a given port.
function killport {
echo '🚨 Killing all processes at port' $1
lsof -ti tcp:$1 | xargs kill
}

Sonoff Basic R3 DIY Mode (LEAST STEPS METHOD, no weird apps, no weird exe files)

Using a sonoff wifi switch, in DIY mode (no flashing required), and octoprint to automatically turn on/off a 3d printer!

Basically just step 2 of this (all the rest can really be ignored): https://tasmota.github.io/docs/Sonoff-DIY/

  1. Follow instructions how to enter DIY mode from Sonoff. This is the excerpt from it:
  1. Long press the button for 5 10 seconds to enter pairing mode, then press another 5 10 seconds to ender Compatible Pairing Mode (AP). The LED indicator should blink continuously.
@marcprux
marcprux / FormDemoApp.swift
Created February 17, 2021 22:54
Example of aligning labels in SwiftUI.Form on macOS
//
// FormDemoApp.swift
// FormDemo
//
// Created by Marc Prud'hommeaux
//
import SwiftUI
@main
@networkingcat
networkingcat / yet_another_motion_automation.yaml
Last active October 21, 2025 13:04 — forked from quallenbezwinger/motion_controlled_scenes_enhanced.yaml
Homeassistant blueprint for motion-activated light scene
blueprint:
name: Yet Another Motion Automation
description: >
# YAMA V10
Turn on lights or scenes when motion is detected.
Four different scenes can be defined depending on time of day.
@jordansinger
jordansinger / macOS.swift
Last active November 17, 2024 02:37
macOS SwiftUI Playgrounds code
import SwiftUI
import PlaygroundSupport
struct Desktop: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
Color(UIColor.systemBlue)
macOS()
}
@stephanecopin
stephanecopin / Publishers+CombineLatestMany.swift
Created February 13, 2020 00:58
An implemention of `CombineLatestMany` for Combine (Swift), which takes takes an array of `Publisher` and return a collection of values, based on their latest value.
import Combine
private protocol LockImplementation {
mutating func lock()
mutating func `try`() -> Bool
mutating func unlock()
}
private struct UnfairLock: LockImplementation {
private var unfairLock = os_unfair_lock_s()
@warpling
warpling / Mento.playground
Last active August 1, 2019 20:11
Copying Tinder's "mentos" button animation (based on tweet: https://twitter.com/warpling/status/930567671015358464?s=20)
//: Playground - noun: a place where people can play
import UIKit
class Mento: UIView {
// The thickness ratio of our mento, 1.0 being a perfect sphere.
let mentoThicknessScale: CGFloat = 0.60
let shape: UIView = {
@jedie
jedie / button_test.py
Last active March 15, 2025 09:46
microPython button irq debouncing
import time
from micropython import const
from machine import Pin, Timer
BUTTON_A_PIN = const(32)
BUTTON_B_PIN = const(33)
class Button:
"""