Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Spahr-Summers jspahrsummers

View GitHub Profile
View EXPatchMasterExample.m
[NSWindow ex_patchInstanceSelector: @selector(sendEvent:) withReplacementBlock: ^(EXPatchIMP *patch) {
return ^(NSEvent *event) {
NSWindow *window = (__bridge NSWindow *) patch->self;
if (window != self.window && [event type] == NSLeftMouseUp && [window isKeyWindow]) {
/* The last view seen */
static NSView *lastView = nil;
NSPoint point = [window.contentView convertPoint: [event locationInWindow] fromView: nil];
NSView *hitView = [window.contentView hitTest: point];
View iflet.m
#import <Foundation/Foundation.h>
#define iflet(LHS, RHS) \
for (id obj_ = (RHS); obj_ != nil;) \
for (LHS = (obj_ ?: (RHS)); obj_ != nil; obj_ = nil)
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString *x = nil;
NSString *y = @"y";
View ViewBindingIsAwesome.m
- (id)initWithFrame:(CGRect)rect {
self = [super initWithFrame:rect];
if (self == nil) return nil;
[self initializeComponent];
RAC(self.title.text) = RACAble(self.viewModel.model.title);
RAC(self.userAndOrgTiles.itemSource) = RACAble(self.viewModel.userAndOrgTiles);
self.loginButton.rac_command = self.viewModel.showLoginCommand;
View gist:4954655
- (RACSignal*)friendsId
{
return [self enqueueWithCursor:-1];
}
- (RACSignal*)enqueueWithCursor:(NSInteger)cursor
{
@weakify(self);
return [[self idsAtCursor:cursor]
// Map each `next` (there should only be one) to a new signal.