Skip to content

Instantly share code, notes, and snippets.

Avatar

Tanner Bennett NSExceptional

View GitHub Profile
@NSExceptional
NSExceptional / HookUIApplicationMain.m
Last active Jul 25, 2022
Hooking UIApplicationMain in Swift or Objc apps with Fishhook
View HookUIApplicationMain.m
// UIApplicationMain accepts Swift.String in Swift apps; a C forward declaration is needed
struct SwiftString {
uint8_t reserved[16];
};
typedef struct SwiftString SwiftString;
int (*orig_UIApplicationMain_objc)(int argc, char *argv[], NSString *_, NSString *delegateClassName) = nil;
int (*orig_UIApplicationMain_swift)(int argc, char *argv[], SwiftString _, SwiftString delegateClassName) = nil;
NSString *(*FoundationBridgeSwiftStringToObjC)(SwiftString str) = nil;
@NSExceptional
NSExceptional / Shell.swift
Created Jun 25, 2022
Leverage @dynamicMemberLookup to invoke shell commands dynamically
View Shell.swift
//
// Shell.swift
//
// Created by Tanner Bennett on 6/25/22.
// Copyright Tanner Bennett (c) 2022
//
import Foundation
extension StringProtocol {
View VoteControl.m
#import "VoteControl.h"
@interface _VoteControl : UIStepper @end
@implementation _VoteControl
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.wraps = YES;
View Transformer<T,U>.swift
import Cocoa
import Foundation
class Person {
var age: Int
var name: String
init(age: Int, name: String) {
self.age = age
self.name = name
@NSExceptional
NSExceptional / BrickLinkHighResImages.js
Last active Dec 21, 2020
A user script to make product images on BrickLink use a larger image file
View BrickLinkHighResImages.js
// ==UserScript==
// @name BrickLink high res images
// @version 0.1
// @description Make product images on BrickLink use a larger image file
// @author Tanner Bennett / @NSExceptional / u/ThePantsThief
// @match https://bricklink.com/*
// @match https://*.bricklink.com/*
// @match https://store.bricklink.com/*
// @grant none
// ==/UserScript==
@NSExceptional
NSExceptional / AutoLayout.md
Last active Dec 8, 2021
The best damn AutoLayout guide I've ever seen
View AutoLayout.md

Edit Feb 4 5:16 PM: Skip to the bottom if you just want the article

It has been brought to my attention that rehosting someone else's content without asking them — even if you link to the original content — is not exactly polite. I did not ask the author before I rehosted his article, and while I feel I should have known better than to that, it just didn't occurr to me. It's not exactly plagarism, but it's still wrong on some level. I have reached out to him now about hosting it here publically, and if he says it's alright, I'll put it back.

You can find the original article here, on his site, and on his Medium page.

@NSExceptional
NSExceptional / StudentLoanDefaultGuide.md
Created Jan 14, 2020
Student Loan Default: The Guide
View StudentLoanDefaultGuide.md

The original guide that was recently deleted here: https://www.reddit.com/r/studentloandefaulters/comments/cg1fd7/student_loan_default_a_guide/

I take no credit for this post, just happened to have it saved in a document and thought I'd be doing an injustice by not sharing this information once I saw the original post was missing! All credit goes to the original author, and without further ado...

Student Loan Default: A Guide

I’ve been wanting to write this for a long time, and seeing that person be in $500,000 of debt and no one really helping him on r/studentloans, I felt it was time to summarize everything I’ve learned. While there is great information on this sub, it is not centralized. It requires some digging. I hope now to bring all of it to the surface.

@NSExceptional
NSExceptional / ClearRunDestinations.applescript
Last active Nov 27, 2019
A simple AppleScript to uncheck "show as run destination" for every device. Open the Devices window first.
View ClearRunDestinations.applescript
activate application "Xcode"
tell application "System Events"
tell process "Xcode"
tell window "Devices"
set deviceList to outline 1 of scroll area 1 of splitter group 1 of group 1
set details to scroll area 1 of splitter group 1 of splitter group 1 of group 1
repeat with r in row of deviceList
select r
-- Uncheck all "Show as run destination" boxes
tell checkbox 1 of details to if value is 1 then click
@NSExceptional
NSExceptional / dark-reader.json
Last active Aug 20, 2021
Manually get and set settings with "Inspect popup" console on the extension
View dark-reader.json
{
"applyToListedOnly": false,
"automation": "",
"changeBrowserTheme": false,
"customThemes": [
{
"theme": {
"brightness": 100,
"contrast": 80,
"darkSchemeBackgroundColor": "#181a1b",
@NSExceptional
NSExceptional / Composition.swift
Created Apr 4, 2019
A demonstration of a use case where inheritance is preferred to composition.
View Composition.swift
protocol Mammal {
var age: Int { get set }
var offspring: Int { get set }
func grow()
func reproduce() -> Self
}
protocol Person: Mammal {
var name: String { get }