Skip to content

Instantly share code, notes, and snippets.

@joelekstrom
joelekstrom / SwiftUIDoubleClickModifier.swift
Last active March 11, 2024 12:02
A view modifier that can reliably detect double clicks on macOS, even in List
extension View {
/// Adds a double click handler this view (macOS only)
///
/// Example
/// ```
/// Text("Hello")
/// .onDoubleClick { print("Double click detected") }
/// ```
/// - Parameters:
/// - handler: Block invoked when a double click is detected

Keybase proof

I hereby claim:

  • I am joelekstrom on github.
  • I am accatyyc (https://keybase.io/accatyyc) on keybase.
  • I have a public key whose fingerprint is FE93 5712 7F78 A5BA 55F2 6F7E 514C 3845 56E2 4388

To claim this, I am signing this object:

@joelekstrom
joelekstrom / open_xcode_file_in_emacs.sh
Last active January 30, 2019 23:04
A bash script that opens the file currently open in Xcode, in Emacs, keeping region
#!/bin/bash
# Use AppleScript to get the open file and selection from Xcode
file_and_selection=$(osascript\
<<EOF
tell application "Xcode"
set current_document to document 1 whose name ends with (word -1 of (get name of window 1))
set current_document_path to path of current_document
set selected_range to selected character range of current_document
set selection_start to first item of selected_range
@joelekstrom
joelekstrom / .nethackrc
Created August 19, 2015 15:18
Nethack config for colors and some nice defaults
OPTIONS=color,menucolors,!autopickup,fruit:pan pizza
# Colorize individual rows on a menu based on what regular expressions match its text
# http://nethackwiki.com/wiki/Menucolors
MENUCOLOR=" blessed "=green
MENUCOLOR=" holy "=green
MENUCOLOR=" uncursed "=yellow
MENUCOLOR=" cursed "=red
MENUCOLOR=" unholy "=red
MENUCOLOR=" cursed .* (being worn)"=orange&underline
@joelekstrom
joelekstrom / gist:25ebb46b04c17520845b
Created June 14, 2015 19:58
Completely reset OSX Server
sudo xcrun xcscontrol --shutdown # Stops Xcode Server
sudo xcrun xcscontrol --reset # Resets Xcode Server, removing all service data and stopping all services
## Thanks to http://blog.stuart.shelton.me/archives/2563