Skip to content

Instantly share code, notes, and snippets.

Steven Troughton-Smith steventroughtonsmith

Block or report user

Report or block steventroughtonsmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@steventroughtonsmith
steventroughtonsmith / UIView+Tooltips.h
Last active Sep 16, 2019
WIP tooltips for Mac Catalyst
View UIView+Tooltips.h
//
// UIView+Tooltips.h
// Crossword
//
// Created by Steven Troughton-Smith on 13/09/2019.
// Copyright © 2019 Steven Troughton-Smith. All rights reserved.
//
#import <UIKit/UIKit.h>
@steventroughtonsmith
steventroughtonsmith / bitcode2intel
Created May 18, 2019
Converts an ARM64 iOS app with Bitcode into an X86_64 variant
View bitcode2intel
#!/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 / Show Tab Overview.py
Last active Jun 3, 2019
'Show Tab Overview' script for Pythonista - adds button to toolbar to show tab overview
View Show Tab Overview.py
# coding: utf-8
from objc_util import *
UIApplication = ObjCClass('UIApplication')
UIBarButtonItem = ObjCClass('UIBarButtonItem')
@on_main_thread
def main():
rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
@steventroughtonsmith
steventroughtonsmith / Foundation.py
Last active May 29, 2019
UIKit+UIFoundation & Foundation for Pythonista - autoconverted from SDK tbd (includes non-public SPI)
View Foundation.py
# coding: utf-8
from objc_util import *
NSAKDeserializer = ObjCClass('NSAKDeserializer')
NSAKDeserializerStream = ObjCClass('NSAKDeserializerStream')
NSAKSerializer = ObjCClass('NSAKSerializer')
NSAKSerializerStream = ObjCClass('NSAKSerializerStream')
NSAbstractLayoutGuide = ObjCClass('NSAbstractLayoutGuide')
NSAddressCheckingResult = ObjCClass('NSAddressCheckingResult')
NSAffineTransform = ObjCClass('NSAffineTransform')
@steventroughtonsmith
steventroughtonsmith / HWKViewController.m
Last active May 10, 2019
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
View HWKViewController.m
//
// 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 / gist:7515380
Last active Apr 2, 2019
iOS 7 UIKeyCommand keydown/keyup and keycode input implementation for a UIResponder. Private API, of course…
View gist:7515380
-(BOOL)canBecomeFirstResponder
{
return YES;
}
-(UIKeyCommand *)_keyCommandForEvent:(UIEvent *)event // UIPhysicalKeyboardEvent
{
NSLog(@"keyCommandForEvent: %@\n\
type = %i\n\
keycode = %@\n\
@steventroughtonsmith
steventroughtonsmith / main.m
Created Mar 24, 2016
Load Mach-O executable at runtime and execute its entry point
View main.m
void callEntryPointOfImage(char *path, int argc, char **argv)
{
void *handle;
int (*binary_main)(int binary_argc, char **binary_argv);
char *error;
int err = 0;
printf("Loading %s\n", path);
handle = dlopen (path, RTLD_LAZY);
@steventroughtonsmith
steventroughtonsmith / ToonyPolymer.shader
Last active Mar 15, 2019
Toon-based plasticky Unity3D shader
View ToonyPolymer.shader
// Plasticky Unity3D shader
// Based on built-in Toon/Lighted
Shader "Custom/ToonyPolymer" {
Properties {
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
_Shininess ("Shininess", Range (0.1, 1)) = 0.7
_Intensity ("Intensity", Range (0.1, 5.0)) = 1.0
@steventroughtonsmith
steventroughtonsmith / gist:6763213
Created Sep 30, 2013
Non-opaque application windows in iOS 7, with optional blur. Shows the user's wallpaper under the app, with Parallax if supported.
View gist:6763213
typedef enum _UIBackgroundStyle {
UIBackgroundStyleDefault,
UIBackgroundStyleTransparent,
UIBackgroundStyleLightBlur,
UIBackgroundStyleDarkBlur,
UIBackgroundStyleDarkTranslucent
} UIBackgroundStyle;
@interface UIApplication (UIBackgroundStyle)
-(void)_setBackgroundStyle:(UIBackgroundStyle)style;
@steventroughtonsmith
steventroughtonsmith / FileBrowser.py
Created Jan 14, 2016
File Browser for Pythonista
View FileBrowser.py
# coding: utf-8
from UIKit import *
from Foundation import *
from ctypes import *
libobjc = CDLL('/usr/lib/libobjc.dylib')
QLPreviewController = ObjCClass('QLPreviewController')
You can’t perform that action at this time.