Skip to content

Instantly share code, notes, and snippets.

@stephancasas
stephancasas / NSApplication+NSResponderDebug.swift
Created March 18, 2024 20:35
An extension on NSApplication providing a computed property that describes the current responder chain.
//
// NSApplication+NSResponderDebug.swift
//
// Created by Stephan Casas on 3/18/24.
//
import Cocoa;
extension NSApplication {
@mitchellh
mitchellh / merge_vs_rebase_vs_squash.md
Last active April 22, 2024 16:22
Merge vs. Rebase vs. Squash

I get asked pretty regularly what my opinion is on merge commits vs rebasing vs squashing. I've typed up this response so many times that I've decided to just put it in a gist so I can reference it whenever it comes up again.

I use merge, squash, rebase all situationally. I believe they all have their merits but their usage depends on the context. I think anyone who says any particular strategy is the right answer 100% of the time is wrong, but I think there is considerable acceptable leeway in when you use each. What follows is my personal and professional opinion:

@kconner
kconner / macOS Internals.md
Last active April 22, 2024 21:28
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@ewhauser
ewhauser / BUILD.bazel
Created April 19, 2022 15:31
Bazel + Gunicorn
gunicorn_binary(
name = "hello",
args = ["hello:app"],
deps = [
"@pypi_flask//:pkg",
],
)
@progrium
progrium / cli.go
Created September 2, 2021 01:13
350 line reimplementation of cobra, simplified and with no dependencies
package cli
import (
"bytes"
"context"
"flag"
"fmt"
"os"
"reflect"
"strings"
@itsthejoker
itsthejoker / dadjoke.py
Created March 13, 2021 21:36
Random dadjoke from fatherhood.gov
#!/usr/bin/env python
# source: 'https://gist.github.com/itsthejoker/33c390748fd8d4184ca81d421b69f9e6'
from urllib import request
import json
import random
resp = request.urlopen("https://fatherhood.gov/jsonapi/node/dad_jokes")
joke = random.choice(json.loads(resp.read()).get('data')).get('attributes')
if joke:
@manmal
manmal / print_advertisingid_usage.sh
Created September 14, 2020 08:51
Find IDFA usage in 3rd party frameworks
for framework in Frameworks/*.framework; do
fname=$(basename $framework .framework)
echo $fname
otool -v -s __TEXT __objc_methname $framework/$fname | grep advertisingIdentifier
done
#!/usr/bin/env python
import argparse
import subprocess
import plistlib
import os
import xml.etree.ElementTree as ET
TEAM = '___YOUR_TEAM_ID__'
@chriszielinski
chriszielinski / NSViewController+NSTextField.swift
Last active February 8, 2024 23:23
NSViewController extension for fetching a window title's NSTextField
extension NSViewController {
var titlebarTextField: NSTextField? {
// NSTitlebarContainerView
guard let titlebarContainerView = view.superview?.subviews
.first(where: { $0.className.hasSuffix("ContainerView") })
else { return nil }
// NSTitlebarView
guard let titlebarView = titlebarContainerView.subviews