Skip to content

Instantly share code, notes, and snippets.

View Geri-Borbas's full-sized avatar
💡

Geri Borbás Geri-Borbas

💡
View GitHub Profile
@Geri-Borbas
Geri-Borbas / controller.m
Last active December 18, 2015 13:18
Pretty clean client code to pop a simple UIAlertView.
[EPPZAlert alertWithTitle:@"Do this?"
message:@"Let me know if you want to do this."
yes:^() { [self do]; }
no:^() { [self dont]; }
cancel:nil];
@Geri-Borbas
Geri-Borbas / controller.m
Last active December 18, 2015 13:18
Custom button titles with EPPZAlert.
[EPPZAlert alertWithTitle:@"Download update?"
message:@"Downloading can take up to 40 seconds! Still want to proceed?"
buttonTitles:@[ @"Upload", @"Later" ]
completition:^(NSString *selectedButtonTitle)
{
if ([selectedButtonTitle isEqualToString:@"Upload"])
[self upload];
if ([selectedButtonTitle isEqualToString:@"Later"])
[self later];
@Geri-Borbas
Geri-Borbas / controller.m
Last active December 18, 2015 13:19
Asking for Reachability is actually three lines of code.
SCNetworkReachabilityRef reachabilityRef = SCNetworkReachabilityCreateWithName(NULL, [@"google.com" UTF8String]);
SCNetworkReachabilityFlags reachabilityFlags;
SCNetworkReachabilityGetFlags(reachabilityRef, &reachabilityFlags);
static void reachabilityCallback(SCNetworkReachabilityRef reachabilityRef, SCNetworkReachabilityFlags flags, void* info)
{
RCViewController *viewController = (__bridge RCViewController*)info; //Cast context object.
[viewController showReachabilityFlags:flags]; //Show.
//Tear down reachability.
SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetMain(), kCFRunLoopDefaultMode);
CFRelease(reachabilityRef);
}
if (asynchronous) //The asynchronous way, NOT WORKS (!!!) with IP addresses as host.
{
//Set callback, dispatch callbacks on a background thread.
SCNetworkReachabilitySetCallback(reachabilityRef, reachabilityCallback, &context);
SCNetworkReachabilitySetDispatchQueue(reachabilityRef, dispatch_queue_create("com.eppz.reachability", nil));
}
else //The synchronous way, works well with IP addresses as host.
{
//Get flags.
SCNetworkReachabilityFlags flags;
@Geri-Borbas
Geri-Borbas / EPPZReachability.m
Created June 17, 2013 09:39
IP address SCNetworkReachability workaround.
if (isAddressReachability)
{
dispatch_async(dispatch_queue_create("com.eppz.reachability.workaround", NULL), ^
{
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
{
//'Manual' invocation of callback functionality.
dispatch_async(dispatch_get_main_queue(), ^ //Dispatch delegate callback on the main thread.
{
#!/bin/sh
#Usage: export_snapshots 'eppz!alert/EPPZAlert.m'
DESTINATION_PATH='Snapshots'
FILE_PATH=$1
FILE_NAME=$(basename $FILE_PATH)
echo 'Exporting <'$FILE_NAME'> located in <'$FILE_PATH'> to <'$DESTINATION_PATH'>.'
@Geri-Borbas
Geri-Borbas / export_snapshots
Created July 12, 2013 17:03
Export every version of a given file from a Git repository.
#!/bin/sh
# Usage:
#
# export_snapshots 'eppz!alert/EPPZAlert.m'
# This will export every revision of the given file to 'Snaphots' folder with a filename scheme below.
#
# Snaphots/0_4a7cb92_BRViewController.m
# Snaphots/1_6cb85c7_BRViewController.m
# Snaphots/2_5550187_BRViewController.m
@Geri-Borbas
Geri-Borbas / UITableView.h
Last active December 19, 2015 23:08
Same as i
//Like documented in http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html
@property(nonatomic,readonly) UITableViewStyle style;
@property(nonatomic,assign) id <UITableViewDataSource> dataSource;
@property(nonatomic,assign) id <UITableViewDelegate> delegate;
@property(nonatomic) CGFloat rowHeight; // will return the default value if unset
@property(nonatomic) CGFloat sectionHeaderHeight; // will return the default value if unset
@property(nonatomic) CGFloat sectionFooterHeight;
@Geri-Borbas
Geri-Borbas / EPPZWrapperView.m
Created October 8, 2013 14:17
Three way to create UIView snapshot containing SpriteKit content.
-(UIImage*)snapshotUsingPrivateApi
{
// Works fine, but private.
CGImageRef snapshot = UIGetScreenImage();
UIImage *snapshotImage = [UIImage imageWithCGImage:snapshot];
return snapshotImage;
}
-(UIImage*)snapshotUsingDrawHierarchy
{