This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Callback { | |
void completed(); | |
} | |
public class AsynchronousTask extends Thread { | |
private Callback callback; | |
private int result; | |
public AsynchronousTask(final Callback callback){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.TimeUnit; | |
import org.junit.Assert; | |
import org.junit.Test; | |
public class AsynchronousTaskTest implements Callback { | |
private CountDownLatch latch; | |
public void completed() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Statement":[ | |
{ | |
"Action":[ | |
"route53:ChangeResourceRecordSets", | |
"route53:GetHostedZone", | |
"route53:ListResourceRecordSets" | |
], | |
"Effect":"Allow", | |
"Resource":[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWS_ACCESS_KEY_ID="<Your access key ID>" | |
AWS_SECRET_ACCESS_KEY="<Your secret access key>" | |
ZONE="<The name of your subdomain>" | |
TTL="600" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Make sure only root can run our script | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
# Load configuration | |
. /etc/route53/config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIResponder+EventInterceptor.h" | |
#import <objc/runtime.h> | |
const char *ASSOC_OBJECT_EVENT_TYPE = "eventType"; | |
const char *ASSOC_OBJECT_EVENT_VALUE = "eventValue"; | |
@implementation UIResponder (EventInterceptor) | |
-(void) setEventValue:(NSString *)eventValue | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIApplication+EventInterceptor.h" | |
#import <objc/runtime.h> | |
#import "EventLogger.h" | |
@implementation UIApplication (EventInterceptor) | |
+(void) load | |
{ | |
//Swap the implementations of our interceptor and the original sendEvent: | |
Method oldMethod = class_getInstanceMethod(self, @selector(sendEvent:)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIViewController+EventInterceptor.h" | |
#import "EventLogger.h" | |
#import <objc/runtime.h> | |
@implementation UIViewController (EventInterceptor) | |
+(void) load | |
{ | |
//Replace the noop viewDidAppear with our own implementation | |
class_replaceMethod(self, @selector(viewDidAppear:), (IMP) viewDidAppear, "v@:@"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "EventLogger.h" | |
NSString *const EVENT_LOGGER_APPEARED = @"appeared"; | |
NSString *const EVENT_LOGGER_TOUCHED = @"touched"; | |
@implementation EventLogger | |
+(void)logEvent:(NSString *)type forObject:(NSObject *)object | |
{ | |
if ([object respondsToSelector:@selector(eventValue)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Standard component trait a-la cake */ | |
trait MessagePrinterComponent { | |
def printer: MessagePrinter | |
trait MessagePrinter{ | |
def printMessage(message: String) | |
} | |
} |