Instantly share code, notes, and snippets.
I build cool things so you can build cooler things. Lover of objc, Swift, and TypeScript. Work account: @tannerbennett-tinderContact me on Mastodon.
NSExceptional /mp4.ts
CreatedApril 21, 2025 21:37
A small class for parsing MP4 file headers, with the ability to check whether the given file has the hvc1 tag. All in-process. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| /* | |
| * mp4.ts | |
| * media | |
| * | |
| * Created by Tanner Bennett on 2025-04-19 | |
| * Copyright © 2025 Tanner Bennett. All rights reserved. | |
| */ | |
| type Atom = { | |
| size: number; |
NSExceptional /tampermonkey-gh-copy-branch-hook.js
CreatedApril 9, 2024 20:24
A Tampermonkey script to change the behavior of the copy branch button on GitHub PRs to copy some markdown instead This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| (function(){ | |
| 'use strict'; | |
| functioncopyMarkdown(){ | |
| ... | |
| navigator.clipboard.writeText(markdown); | |
| } | |
| functionaddEventsToCopyElements(){ | |
| // Get all elements with tag name clipboard-copy and class js-copy-branch |
NSExceptional /cpp_lookup.mm
CreatedNovember 3, 2022 23:07
Lookup and invoke a CPP function at runtime This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #import<Foundation/Foundation.h> | |
| #include<string> | |
| #include<dlfcn.h> | |
| classFoo { | |
| int bar =0; | |
| std::stringtoString(); | |
| }; | |
| std::stringFoo::toString() { |
NSExceptional /HookUIApplicationMain.m
Last activeNovember 2, 2022 17:27
Hooking UIApplicationMain in Swift or Objc apps with Fishhook This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| //UIApplicationMainacceptsSwift.StringinSwiftapps;aCforwarddeclarationisneeded | |
| structSwiftString { | |
| uint8_treserved[16]; | |
| }; | |
| typedefstructSwiftStringSwiftString; | |
| 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 /Shell.swift
CreatedJune 25, 2022 23:31
Leverage @dynamicMemberLookup to invoke shell commands dynamically This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| // | |
| // Shell.swift | |
| // | |
| // Created by Tanner Bennett on 6/25/22. | |
| // Copyright Tanner Bennett (c) 2022 | |
| // | |
| import Foundation | |
| extensionStringProtocol{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #import"VoteControl.h" | |
| @interface_VoteControl :UIStepper@end | |
| @implementation_VoteControl | |
| - (instancetype)initWithFrame:(CGRect)frame { | |
| self = [superinitWithFrame:frame]; | |
| if (self) { | |
| self.wraps =YES; |
NSExceptional /Transformer<T,U>.swift
Last activeApril 13, 2021 20:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| import Cocoa | |
| import Foundation | |
| class Person{ | |
| varage:Int | |
| varname:String | |
| init(age:Int, name:String){ | |
| self.age= age | |
| self.name= name |
NSExceptional /BrickLinkHighResImages.js
Last activeDecember 21, 2020 22:02
A user script to make product images on BrickLink use a larger image file This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| // ==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 /AutoLayout.md
Last activeApril 26, 2025 13:07
The best damn AutoLayout guide I've ever seenEdit 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 articlehere, on his site, and onhis Medium page.
NewerOlder