Skip to content

Instantly share code, notes, and snippets.

@orta
orta / network-models.md
Last active August 29, 2015 13:56
Network models

Using a real artsy example from today.

Creating a follow button on a view controller for different types of objects Artist, Profile, Gene

Needs: networking Needs: layout Needs: interface changes based on networking

Networking

@jeremy-w
jeremy-w / bitmask.m
Last active August 29, 2015 13:57
Beware truncation when testing option bits or other bitmasks. Also: Why _Bool is better than BOOL.
//cc -Weverything -fobjc-arc -framework Foundation bitmask.m -o bitmask
/** @file bitmask.m
* @author Jeremy W. Sherman (@jeremy-w on Github)
* @license ISC (http://opensource.org/licenses/isc-license.txt)
*
* Provides an example where assignment of the result of a naive bitmask check
* to BOOL fails.
*
* Demonstrates 2 ways to avoid this issue.
*
@steipete
steipete / Test.m
Last active August 29, 2015 13:57
[PSPDFHUDView updatePageLabelFrameAnimated:] resizes a label that is inside PSPDFHUDView by calling sizeToFit. This triggers layoutSubviews on PSPDFHUDView. That's something I would like to prevent. What could I do here? Followup: https://gist.github.com/steipete/9725247
(lldb) bt
* thread #1: tid = 0x6e9f, 0x0036d774 PSPDFCatalog`-[PSPDFDebugLayer setNeedsLayout](self=0x1656a190, _cmd=0x302e001d) + 44 at PSPDFDebugHelper.m:456, queue = 'com.apple.main-thread', stop reason = breakpoint 14.1
frame #0: 0x0036d774 PSPDFCatalog`-[PSPDFDebugLayer setNeedsLayout](self=0x1656a190, _cmd=0x302e001d) + 44 at PSPDFDebugHelper.m:456
frame #1: 0x2f9763e8 QuartzCore`CA::Layer::property_did_change(CA::Transaction*, unsigned int) + 1188
frame #2: 0x2f975f1c QuartzCore`CA::Layer::end_change(CA::Transaction*, unsigned int, objc_object*) + 64
frame #3: 0x2f976a54 QuartzCore`CA::Layer::set_bounds(CA::Rect const&, bool) + 540
frame #4: 0x2f976776 QuartzCore`-[CALayer setBounds:] + 110
frame #5: 0x2f97789c QuartzCore`-[CALayer setFrame:] + 636
frame #6: 0x2fcf6336 UIKit`-[UIView(Geometry) setFrame:] + 254
frame #7: 0x2fd075f4 UIKit`-[UIView(Geometry) sizeToFit] + 304
// 64-bit helper from <tgmath.h>
// Extracted because those overrides won't work with Modules.
#undef fmin
#define fmin(__x, __y) __tg_fmin(__tg_promote2((__x), (__y))(__x), \
__tg_promote2((__x), (__y))(__y))
#undef fmax
#define fmax(__x, __y) __tg_fmax(__tg_promote2((__x), (__y))(__x), \
__tg_promote2((__x), (__y))(__y))
@bnickel
bnickel / fix-xcode
Last active August 29, 2015 14:08 — forked from rnapier/fix-xcode
#!/usr/bin/python
# fix-xcode
# Rob Napier <robnapier@gmail.com>
# Script to link in all your old SDKs every time you upgrade Xcode
# Create a directory called /SDKs (or modify source_path).
# Under it, put all the platform directories:
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform
# Under those, store the SDKs:
+ (AppDelegate *)sharedAppDelegate {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
@jakemarsh
jakemarsh / gist:592329
Created September 22, 2010 19:28
Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Your users will thank you. A lot.
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.view endEditing:YES];
}
//The endEditing: method on UIView comes to us from a category that UITextField adds to UIKit that makes the view or any subview that is the first responder resign (optionally force), that's what the "YES" bit is.
@alloy
alloy / ios-release-hockey-app.rake
Created January 30, 2012 18:06
Rake tasks to create an iOS app archive and push dSYM to HockeyApp.
module Gem; end
require 'rubygems/version'
namespace :version do
module InfoPlist
extend self
def [](key)
output = `/usr/libexec/PlistBuddy -c 'Print #{key}' Bananas-Info.plist`.strip
@calebd
calebd / README.md
Created July 19, 2012 14:49
A better build date script for Xcode

A Better Build Date

Showing a build date in an app is pretty easy using __DATE__ and __TIME__ but the format is fixed. This script allows you to control the date and time format and pull the build date from the Info.plist using the CMDBundleBuildTime key.

{
"auto_indent": true,
"auto_match_enabled": true,
"caret_style": "smooth",
"close_windows_when_empty": true,
"color_scheme": "Packages/Theme - Aqua/Color Schemes/Tomorrow Night Aqua.tmTheme",
"detect_indentation": true,
"dictionary": "Packages/Language - English/en_US.dic",
"draw_centered": false,
"draw_indent_guides": true,