Skip to content

Instantly share code, notes, and snippets.

View aug2uag's full-sized avatar

Reza Fatahi aug2uag

  • Los Angeles, CA
View GitHub Profile
#!/usr/bin/env ruby
require 'rubygems'
require 'ruby_odata'
svc = OData::Service.new "http://odata.netflix.com/Catalog/"
puts "DVD:"
svc.Titles.filter("AverageRating le 2 and Type eq 'Movie' and Dvd/Available eq true").order_by("AverageRating asc").top(100)
movies = svc.execute
@aug2uag
aug2uag / gist:5367393
Last active December 16, 2015 03:09
Objective-C constructor example
@interface ClassName : NSObject
{
int integer_instance_variable;
NSString *string_instance_variable;
//add ivars as needed
}
@end
@implementation ClassName
@aug2uag
aug2uag / gist:5367417
Created April 11, 2013 21:38
Objective-C destructor example
-(void)dealloc {
delete obj;
[super dealloc];
}
@aug2uag
aug2uag / applicationActivationCount
Created September 30, 2013 15:44
NSNotificationCenter ApplicationDidBecomeActive
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
NSInteger count = [APPLICATION_COUNT_VALUE integerValue];
count++;
[self.textLabel setText:[NSString stringWithFormat:@"%i", count]];
}];
@aug2uag
aug2uag / AppleXCTests
Last active December 25, 2015 17:18
XCTest Framework
//
// Copyright (c) 2013 Apple Inc. All rights reserved.
//
// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved.
//
// Use of this source code is governed by the following license:
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
@aug2uag
aug2uag / gist:8203371
Created December 31, 2013 23:40
Respond UIImage to retina
if ([UIScreen mainScreen].scale == 2.0) {
// download 2x
}
@aug2uag
aug2uag / PseudoDateFormatter
Last active January 1, 2016 21:29
PseudoDateFormatter, custom UITextField input month/year expiration
#import "ViewController.h"
@interface ViewController () <UITextFieldDelegate>
@property (strong, nonatomic) UITextField *textField;
@end
@implementation ViewController
- (void)viewDidLoad
{
@aug2uag
aug2uag / gist:8212026
Last active January 1, 2016 22:48
ÜberSimplePing
NSString* urlString = <# INSERT_URL_HERE #>;
CFHostRef _host;
CFSocketRef _socket;
assert(self->_host == NULL);
self->_host = CFHostCreateWithName(NULL, (__bridge CFStringRef) urlString);
assert(self->_host != NULL);
CFHostScheduleWithRunLoop(self->_host, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
// CFHostStartInfoResolution(self->_host, kCFHostNames, 0);
@aug2uag
aug2uag / gist:8213005
Created January 1, 2014 23:49
ConvenientLaunchSafari
NSString* url = <# URL_HERE #>;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
@aug2uag
aug2uag / gist:8213106
Created January 2, 2014 00:02
UIActivityViewController
NSString* textToShare = <# INPUT #>;
UIImage* imageToShare = <# INPUT #>;
NSArray* thingsToShare = @[textToShare, imageToShare];
UIActivityViewController* activityViewController = [[UIActivityViewController alloc] initWithActivityItems:thingsToShare applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];