Skip to content

Instantly share code, notes, and snippets.

View rcoh's full-sized avatar

Russell Cohen rcoh

View GitHub Profile
@rcoh
rcoh / enableview.m
Last active December 20, 2015 03:29
Enabling a View
[self.view INKEnableWithUTI:myFile.uti dynamicBlob:^INKBlob *{
INKBlob *blob = [INKBlob blobFromData:[myFile getData]];
blob.uti = myFile.uti;
blob.filename = myFile.fileName;
return blob;
} returnBlock:^(INKBlob *blob, INKAction *action, NSError *error) {
if ([action.type isEqualToString: INKActionType_Return]) {
// Return save action. Save back the blob
} else {
// Return cancel action
#import <Ink/Ink.h>
@rcoh
rcoh / inkimports.m
Last active December 20, 2015 03:29
#import <INK/Ink.h>
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[INKCore runBackgroundProcess];
/*Your code here*/
}
@rcoh
rcoh / openurl.m
Last active December 20, 2015 03:29
//This method is used instead of the handleOpenURL method because it is depreciated in iOS 6 and only one of the methods can be used
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if ([Ink openURL:url sourceApplication:sourceApplication annotation:annotation]) {
return YES;
}
// Add whatever other url handling code your app requires here
return NO;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Ink setupWithAppKey:@"your-appkey-here"];
/*Your app's intialization code here*/
}
for (loop_cond) {
int x = 2;
if (x > 1) {
x = -5;
}
print(x);
}
// If we hoist x = 2, then we'll only print once
// If we don't we'll print every time.
try:
thrower()
except (Exception1, Exception2):
print DoStuff
try:
thrower()
except NastyException, e:
print "Uh oh. We threw an", e
import exception_package
try:
thrower()
except exception_package.Exp1, exception_package.Exp2:
pass