Skip to content

Instantly share code, notes, and snippets.

Andrew Sardone andrewsardone

Block or report user

Report or block andrewsardone

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Using Calca for design

Below, the variables and examples were taken verbatim from [Using Soulver for design][sfd].

I'm just posting this as a reference, and example of sharing plain text documents for use within Calca. [sfd]:

Variables and examples

iPhoneW = 320
andrewsardone / gist:6076443
Last active Dec 20, 2015
I'm trying my hardest to make sure @cdzombak can't read this code.
View gist:6076443
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
if (object == self && context == self.kvoContext) {
((void (^)(void)) @{
@"addresses": ^{ self.peep.address = [self dictionaryForArrayOfValues:self.addresses]; },
@"emails": ^{ = [self dictionaryForArrayOfValues:self.emails]; },
}[keyPath] ?: ^{})();
else if (object == self.peep && context == self.kvoContext) {
((void (^)(void)) @{

I was linked to this post by Mark Wilson via a tweet from Tim O'Reilly:

This critique of an Apple ad may well be the most important thing you'll read this year: Take it seriously.

My terse comment on Twitter summed up my response, but I decided to follow O'Reilly's lead and “take [the piece] seriously.” I'll try to keep it short.

View gist:5911782

Fresh clone and test of script/ci:

git clone \
  && cd UITextView-UIControl \
  && git checkout -t origin/ci \
  && script/bootstrap \
  && script/ci

To form a parent-child relationship:

  1. Send the -addChildViewController: message to the parent with the child as the parameter. This will send the -willMoveToParentViewController: message to the child with the parent as the parameter.
  2. Add the child view controller's view as a subview to the parent view controller's view.
  3. Send the -didMoveToParentViewController: message to the child with the parent as the parameter.

For example,

[parent addChildViewController:child];
View AbstractViewController.h
#import <UIKit/UIKit.h>
@interface AbstractViewController : UIViewController
@property (nonatomic, strong) Class specialButtonClass;
@property (nonatomic, strong) IBOutlet UIButton *specialButton; // laid out in nib
View gist:5652968
// 1.
// “Safe” but retain cycle.
[self setCompletionBlock:^{
NSLog(@"1: %@", self->_foo);
// 2.
// Unsafe. Could dereference nil.
__weak BCThing *weakSelf = self;
View gist:5228121
require 'delegate'
require 'test/unit'
class Displayer < SimpleDelegator
# alias_method from post originally out of order:
# alias_method :__getobj__, :object
alias_method :object, :__getobj__
andrewsardone / gist:4150919
Created Nov 26, 2012
Programmatic UISearchDisplayController retain issue
View gist:4150919
#import <UIKit/UIKit.h>
@interface ExampleViewController : UIViewController
#pragma mark -
@implementation ExampleViewController
- (void)viewDidLoad
View gist:4014223


Feature Requests

  • insert-mode
    • ignore all commands until you hit esc to exit
  • Scroll to top of the page with gg
  • Scroll to bottom of the page with G
  • Scroll a page up with u
  • Scroll a page down with d
You can’t perform that action at this time.