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
View using-calca-for-design.md

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]: http://bjango.com/articles/soulver/

Variables and examples

iPhoneW = 320
@andrewsardone
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.peep.email = [self dictionaryForArrayOfValues:self.emails]; },
}[keyPath] ?: ^{})();
}
else if (object == self.peep && context == self.kvoContext) {
((void (^)(void)) @{
View response-to-wilson-post-on-apple-ad.md

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: http://bit.ly/115U5uT 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 https://github.com/andrewsardone/UITextView-UIControl \
  && cd UITextView-UIControl \
  && git checkout -t origin/ci \
  && script/bootstrap \
  && script/ci
View UIViewControllerContainment.md

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
@end
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'
# http://www.saturnflyer.com/blog/jim/2013/03/21/ruby-delegate-rb-secrets/
class Displayer < SimpleDelegator
# alias_method from post originally out of order:
# alias_method :__getobj__, :object
alias_method :object, :__getobj__
@andrewsardone
andrewsardone / gist:4150919
Created Nov 26, 2012
Programmatic UISearchDisplayController retain issue
View gist:4150919
#import <UIKit/UIKit.h>
@interface ExampleViewController : UIViewController
@end
#pragma mark -
@implementation ExampleViewController
- (void)viewDidLoad
View gist:4014223

vimari

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.