Skip to content

Instantly share code, notes, and snippets.

View steventroughtonsmith's full-sized avatar

Steven Troughton-Smith steventroughtonsmith

View GitHub Profile
@steventroughtonsmith
steventroughtonsmith / gist:7515380
Last active April 2, 2019 01:38
iOS 7 UIKeyCommand keydown/keyup and keycode input implementation for a UIResponder. Private API, of course…
-(BOOL)canBecomeFirstResponder
{
return YES;
}
-(UIKeyCommand *)_keyCommandForEvent:(UIEvent *)event // UIPhysicalKeyboardEvent
{
NSLog(@"keyCommandForEvent: %@\n\
type = %i\n\
keycode = %@\n\
@steventroughtonsmith
steventroughtonsmith / gist:52f0c6783446b6fc536e
Created January 17, 2016 06:49
NSExtensionSDK providers
AddressBookUI.framework
(
"com.apple.people-picker"
)
AudioToolbox.framework
(
"com.apple.AudioUnit",
"com.apple.AudioUnit-UI"
@steventroughtonsmith
steventroughtonsmith / UIColor+AccentColor.m
Created October 27, 2019 16:55
[Catalyst] Provides access to macOS Accent Color
@implementation UIColor (AppleAccentColor)
+(UIColor *)CATALYSTAccentColor
{
BOOL hasAccentSet = ([[NSUserDefaults standardUserDefaults] objectForKey:@"AppleAccentColor"] != nil);
NSInteger systemAccentColor = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleAccentColor"];
UIColor *returnColor = [UIColor systemBlueColor];
if (hasAccentSet)
@steventroughtonsmith
steventroughtonsmith / gist:6788b6c340a0aa52345a
Created October 27, 2015 05:19
Run OS X Screen Saver as Wallpaper
/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background
@steventroughtonsmith
steventroughtonsmith / HWKViewController.m
Last active May 31, 2020 23:55
Example of dynamic iOS UI that changes based on the connection/disconnection of a hardware keyboard, based on suggestions from @JohnRHeaton. Requires linking to private GraphicsServices framework. rdar://problem/15447952
//
// HWKViewController.m
// HardwareKeyboardUI
//
// Created by Steven Troughton-Smith on 13/11/2013.
// Copyright (c) 2013 High Caffeine Content. All rights reserved.
//
#import "HWKViewController.h"
@steventroughtonsmith
steventroughtonsmith / Add Web Tab.py
Created January 13, 2016 22:55
Insert a custom browser tab into Pythonista
# coding: utf-8
from Foundation import *
from QuartzCore import *
from UIKit import *
import console
WKWebView = ObjCClass('WKWebView')
@on_main_thread
@steventroughtonsmith
steventroughtonsmith / FileBrowser.py
Created January 14, 2016 22:18
File Browser for Pythonista
# coding: utf-8
from UIKit import *
from Foundation import *
from ctypes import *
libobjc = CDLL('/usr/lib/libobjc.dylib')
QLPreviewController = ObjCClass('QLPreviewController')
@steventroughtonsmith
steventroughtonsmith / PSTLDraggableColorSwatchView.h
Last active May 6, 2021 00:47
Color Swatch view for Mac Catalyst that implements inter-app drag & drop
//
// PSTLDraggableColorSwatchView.h
// Pastel
//
// Created by Steven Troughton-Smith on 06/03/2020.
// Copyright © 2020 Steven Troughton-Smith. All rights reserved.
//
@import UIKit;
@steventroughtonsmith
steventroughtonsmith / bitcode2intel
Created May 18, 2019 15:31
Converts an ARM64 iOS app with Bitcode into an X86_64 variant
#!/bin/bash
TARGET="$( cd "$(dirname "$1")" ; pwd -P )/$1"
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
TARGET_ARCH=x86_64
export IPHONEOS_DEPLOYMENT_TARGET=12.2
rm -r /tmp/bitcode2intel
mkdir -p /tmp/bitcode2intel
pushd /tmp/bitcode2intel
@steventroughtonsmith
steventroughtonsmith / palettes.txt
Created June 9, 2020 19:24
Pastel 1.0 default palettes
{
"Autumn Approaches" => {
"colors" => [
0 => "#220204"
1 => "#9f311b"
2 => "#e17817"
3 => "#6a1d18"
4 => "#d64019"
]
}