Skip to content

Instantly share code, notes, and snippets.

View 0xced's full-sized avatar

Cédric Luthi 0xced

View GitHub Profile
@landonf
landonf / disassembly.txt
Last active October 3, 2019 18:18
Explaining the File:/// bug. See also http://openradar.appspot.com/13128709
In DDResultCopyExtractedURL in the DataDetectorsCore.framework, file:// URLs are sanity-checked with an assert:
0xCB86 loc_CB86:
0xCB86 lea rsi, cfstr_File ; "file://"
0xCB8D mov rdi, rbx
0xCB90 call _CFStringHasPrefix ; Check if the string starts with 'file://'
; Yes, this is case sensitive, which is why the test fails
0xCB95 test al, al
0xCB97 jne short loc_CBD4 ; If CFStringHasPrefix returns true, jump past the assert
; Otherwise, the following code triggers an assert:
@mattt
mattt / uiappearance-selector.md
Last active February 7, 2025 15:27
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@karstenBriksoft
karstenBriksoft / gist:5308470
Created April 4, 2013 07:16
how to submit apps that contain the growl xpc to the app store without loosing entitlements for the xpc
replace _appName_ with the name of your app (i.e. Contacts.app)
- open Terminal window
find /var/folders -name _appName_ 2>/dev/null
- delete all folders that were found
- build & archive _appName_
- open archive in Finder, locate _appName_
- open gdb
@steipete
steipete / PSPDFViewController.h
Last active June 6, 2017 03:56
This method will help to prevent a lot of emails about "weird bugs".
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)
anonymous
anonymous / Either.cs
Created June 13, 2013 21:03
A C# implementation of haskell's Either.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Util
{
public class Either<TLeft, TRight> : IEither<TLeft, TRight>
{
@ddeville
ddeville / gist:6078492
Last active December 20, 2015 05:29
objc_msgSend cast
So:
id boxedValue = objc_msgSend(self, mappingSelector, instance, value, boxingParameters);
would become:
id boxedValue = ((id (*)(id, SEL, id, id, id))objc_msgSend)(self, mappingSelector, instance, value, boxingParameters);
The first `id` and `SEL` are basically `self` and `_cmd`, the first 2 arguments in any objc_msgSend.
@JaviSoto
JaviSoto / gist:6516942
Created September 10, 2013 22:57
iOS 7 Parallax effect
@interface UIView (JSParallaxEffect)
- (void)js_addParallaxEffectWithMaxOffset:(CGFloat)maxOffset;
@end
@steipete
steipete / UIKitLegacyDetector.m
Last active April 29, 2025 20:17
A simple way to detect at runtime if we're running in UIKit legacy mode or the new "flat" variant. Written for our PDF iOS SDK (http://pspdfkit.com), where the precompiled binary needs to detect at runtime in what variant it's running. Want more stuff like that? Follow me on Twitter: http://twitter.com/steipete
// Taken from http://PSPDFKit.com. This snippet is under public domain.
#define UIKitVersionNumber_iOS_7_0 0xB57
BOOL PSPDFIsUIKitFlatMode(void) {
static BOOL isUIKitFlatMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7.
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0;
}
import lldb
import re
import shlex
# This script allows Xcode to selectively ignore Obj-C exceptions
# based on any selector on the NSException instance
def getRegister(target):
if target.triple.startswith('x86_64'):
return "rdi"
@FiloSottile
FiloSottile / 32.asm
Last active January 31, 2025 03:22
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4