Skip to content

Instantly share code, notes, and snippets.

View phatblat's full-sized avatar

Ben Chatelain phatblat

View GitHub Profile
@phatblat
phatblat / gist:d71619bb1e65b204707b
Created June 15, 2013 14:42
WWDC 2013 Video Index
https://developer.apple.com/wwdc/videos/
* 100 - Keynote
* 101 - Platforms State of the Union
* 102 - Apple Design Awards
* 109 - Painting the Future (MARI on OS X)
* 200 - Accessibility in OS X
* 201 - Building User Interfaces for iOS 7
* 202 - Accessibility in iOS
* 203 - What's New in Cocoa Touch
@phatblat
phatblat / gist:9120111
Created February 20, 2014 18:26
Find keyboard on iOS 7
- (UIView *)findKeyboard
{
// Locate non-UIWindow.
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
@phatblat
phatblat / crashlytics.rb
Created June 13, 2014 20:12
CrashlyticsFramework pod run script that works with local (:path) installs by dynamically detecting where the pod was installed
#!/usr/bin/env ruby
# crashlytics.rb
#
# Created by Ben Chatelain on 5/13/14.
# Alternate values make much of this script testable from outside Xcode
if ARGV.length > 0
args = ARGV.join(" ")
else
@phatblat
phatblat / sparse_checkout.sh
Last active August 29, 2015 14:06
Git sparse checkout
tmpdir=/tmp/phatblat-images
subdir=images/
remote_git=git://github.com/phatblat/phatblat.github.io.git
remote_https=https://github.com/phatblat/phatblat.github.io.git
mkdir $tmpdir
cd $tmpdir
git init
git remote add -f origin $remote_git || \
git remote set-url origin $remote_https && \
@phatblat
phatblat / POD_NAME.podspec
Created October 20, 2014 15:30
POC of a Pod which installs a run script into Xcode (CocoaPods 0.33 or less)
Pod::Spec.new do |s|
s.name = 'POD_NAME'
s.version = '1.0.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'Example of pod which installs a run script into the Xcode project (first target)'
s.homepage = 'https://github.com/phatblat/POD_NAME'
s.authors = { 'Ben Chatelain' => 'benchatelain@gmail.com' }
s.source = { :git => 'https://github.com/phatblat/POD_NAME.git', :tag => s.version.to_s }
s.ios.deployment_target = '6.0'
@phatblat
phatblat / gist:e354c5c7b21a9f557f88
Created October 24, 2014 16:42
iOS Model Identifier
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = calloc(1, size);
if (machine) {
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSLog(@"modelIdentifier: %@", @(machine));
free(machine);
}
@phatblat
phatblat / Info.plist
Last active September 13, 2016 05:39
Fabric frameworks
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Fabric</key>
<dict>
<key>APIKey</key>
<string>xxxxxxxxxxxx</string>
<key>Kits</key>
<array>
@phatblat
phatblat / libgit2certs.m
Created November 11, 2014 17:39
An example of configuring libgit2 on iOS to use the root CA cert for GitHub
#import <git2/common.h>
NSString *const CACertificateFile_DigiCert = @"DigiCert High Assurance EV Root CA.pem";
NSString *const certFilePath = [[NSBundle mainBundle].bundlePath stringByAppendingPathComponent:CACertificateFile_DigiCert];
NSLog(@"Loading certificate: %@", certFilePath);
const char *file = certFilePath.UTF8String;
const char *path = NULL;
int returnValue = git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, file, path);
@phatblat
phatblat / gist:04b8ef20654432ae6549
Created January 8, 2015 21:08
Find the main app bundle from inside an extension bundle
NSBundle *bundle = [NSBundle mainBundle];
if ([[bundle.bundleURL pathExtension] isEqualToString:@"appex"]) {
// Peel off two directory levels - MY_APP.app/PlugIns/MY_APP_EXTENSION.appex
bundle = [NSBundle bundleWithURL:[[bundle.bundleURL URLByDeletingLastPathComponent] URLByDeletingLastPathComponent]];
}
NSURL *url = [bundle URLForResource:... withExtension:...];
@phatblat
phatblat / AppDelegate.m
Last active May 14, 2020 08:17
Repost NSUserDefaultsDidChangeNotification to iOS extensions
#pragma mark - App Singleton
- (instancetype)init {
...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDefaultsDidChange:) name:NSUserDefaultsDidChangeNotification object:nil];
...
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];