Skip to content

Instantly share code, notes, and snippets.

@jonathan-beebe
jonathan-beebe / iOS_open_mail_app.m
Created July 21, 2015 20:51
Open the default Apple Mail app on iOS navigating to a non-existent message id.
// Open the mail app on iOS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"message:xxxxxxxx"]];
@jonathan-beebe
jonathan-beebe / ocmock_example.m
Created September 2, 2015 12:28
OCMock Examples
#import <OCMock/OCMock.h>
...
// The basic object
id obj = [[MyOjbect alloc] init];
// Create the mock
id objMock = OCMPartialMock(obj);
@jonathan-beebe
jonathan-beebe / xcode_async_swift.playground
Created September 4, 2015 00:47
Xcode Swift playgrounds do not normally run async code. You must tell the playground to continue indefinitely.
import XCPlayground
import Foundation
...
XCPSetExecutionShouldContinueIndefinitely(true)
@jonathan-beebe
jonathan-beebe / UIImage+UISegmentIconAndText.h
Created September 28, 2012 18:59
Create a UIImage from an icon file and string for use in a UISegmentControl - Allows for UISegment buttons with icons and text.
#import <UIKit/UIKit.h>
@interface UIImage (UISegmentIconAndText)
+ (id) imageFromImage:(UIImage*)image string:(NSString*)string color:(UIColor*)color;
@end
@jonathan-beebe
jonathan-beebe / fix_alcatraz_plugins.sh
Last active December 9, 2015 18:36
Fixing Alcatraz after upgrading Xcode
# Upgrading Xcode can wreak havok on your custom Alcatraz setup.
# Each plugin must list the UUIDs of Xcode that it supports. Thus
# with each new release we must update the list of UUIDs for each
# plugin we want to continue using.
#
# You can discover the UUID of an Xcode app bundle by running this command
defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID
# > 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90
@jonathan-beebe
jonathan-beebe / curried_functions.swift
Last active December 21, 2015 13:27
curried functions in Swift
// Here is a manually curried function.
// maxA takes an int and returns a function, maxB, that takes an int and returns an int.
func maxA(a:Int) -> (Int) -> Int {
func maxB(b:Int) -> Int {
return a > b ? a : b
}
return maxB
}
<!DOCTYPE html>
<html lang="html">
<head>
<style>
.videoWrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
@jonathan-beebe
jonathan-beebe / UICTContentSizeCategory
Created February 5, 2016 22:05
UICTContentSizeCategory logs for each category
```
UICTContentSizeCategoryXS
Caption 1 = {size: 11pts, weight:normal}
default = {size: 13pts, weight:normal}
Body = {size: 14pts, weight:normal}
Subhead = {size: 12pts, weight:normal}
Title 1 = {size: 25pts, weight:normal}
@jonathan-beebe
jonathan-beebe / async_helpers.swift
Created May 16, 2016 16:38
Helpers to make dispach_* code in Swift a bit more concise.
import Foundation
func async(callback:(Void -> Void)) {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
callback()
})
}
func after(delay:Double, closure:Void->Void) {
dispatch_after(
@jonathan-beebe
jonathan-beebe / .bash_profile+xcode
Last active June 12, 2016 22:39
Helpful bash aliases for Xcode projects
alias xw="open *.xcworkspace"
alias xp="open *.xcodeproj"
function xcode {
# If the pattern matches a workspcace file, try to open it.
if stat -t -- *.xcworkspace >/dev/null 2>&1; then
xw
# Otherwise fall back to opening a project file.
else
xp