Skip to content

Instantly share code, notes, and snippets.

@nickdowell
nickdowell / gist:b446a3f987c8b6e16d2abc6e67b4b7a3
Created November 28, 2022 08:09
Predefined preprocessor macros (clang)
View gist:b446a3f987c8b6e16d2abc6e67b4b7a3
$ clang -dM -E -x c++ /dev/null
#define _LP64 1
#define __AARCH64EL__ 1
#define __AARCH64_CMODEL_SMALL__ 1
#define __AARCH64_SIMD__ 1
#define __APPLE_CC__ 6000
#define __APPLE__ 1
#define __ARM64_ARCH_8__ 1
#define __ARM_64BIT_STATE 1
View clang-tidy.sh
#!/bin/zsh
set -euxo pipefail
sdk_path=`xcrun -f --sdk iphoneos --show-sdk-path`
plat_path=`xcrun -f --sdk iphoneos --show-sdk-platform-path`
$CLANG_TIDY \
Sources/MyLibrary/**/*.mm -- \
-ISources/MyLibrary/include \
View apple-releases.md
View Xcode_warning_settings.txt
CLANG_WARN__DUPLICATE_METHOD_MATCH
37a38
> -Wduplicate-method-match
CLANG_WARN__EXIT_TIME_DESTRUCTORS
37c37
< -Wno-exit-time-destructors
---
> -Wexit-time-destructors
View keybase.md

Keybase proof

I hereby claim:

  • I am nickdowell on github.
  • I am nickdowell (https://keybase.io/nickdowell) on keybase.
  • I have a public key ASCVNmhBpxVhpMEx_FXUvs5_LQy5W9TLiiE3gNjGFzB1lQo

To claim this, I am signing this object:

View aps_environment.m
NSString *getApsEnvironment()
{
NSString *provisioningPath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
if (!provisioningPath)
return (NSString *)nil;
// NSISOLatin1 keeps the binary wrapper from being parsed as unicode and dropped as invalid
NSScanner *scanner = [NSScanner scannerWithString:[NSString stringWithContentsOfFile:provisioningPath encoding:NSISOLatin1StringEncoding error:NULL]];
if (![scanner scanUpToString:@"<plist" intoString:nil])
return (NSString *)nil;
View ios_device_lockstate.m
#import <Foundation/Foundation.h>
#import <notify.h>
void test()
{
int notify_token;
notify_register_dispatch("com.apple.springboard.lockstate", &notify_token, dispatch_get_main_queue(), ^(int token) {
uint64_t state = UINT64_MAX;
notify_get_state(token, &state);
NSLog(@"com.apple.springboard.lockstate = %llu", state);
View ReadEntitlementsFromCodeSignature.m
#import <dlfcn.h>
#import <mach-o/dyld.h>
#import <mach-o/loader.h>
int main(int argc, char *argv[]) {
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] executablePath]];
NSData *codeSignatureData = nil;
@nickdowell
nickdowell / auto_examples
Last active August 29, 2015 14:01
automount configuration examples
View auto_examples
# /etc/auto_examples
afp_vol -fstype=afp afp://user:password@server/afp_vol
smb_vol -fstype=smbfs ://user:password@server/smb_vol
#note: no password can be specified for NFS
nfs_vol server:/nfs_vol
View ParseMobileProvision.m
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]];
const char *ptr = [data bytes], *start = NULL, *end = NULL;
for (size_t i = 0; i < [data length] - 8; i++) {
if (memcmp(ptr + i, "<plist", 6) == 0) {
start = ptr + i;
}
if (memcmp(ptr + i, "</plist>", 8) == 0) {
end = ptr + i + 8;
}
}