Skip to content

Instantly share code, notes, and snippets.

View craigmarvelley's full-sized avatar

Craig Marvelley craigmarvelley

View GitHub Profile
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.swing.event.*;
public class Internet extends JFrame
{
final JDesktopPane theDesktop;
@craigmarvelley
craigmarvelley / launch_instances_role.yml
Created May 23, 2014 08:51
Launch and provision EC2 instances in one go
---
- name: Launch new instances
local_action:
module: ec2
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
region: "{{ ec2_region }}"
keypair: "{{ ec2_keypair }}"
group: "{{ ec2_group }}"
@craigmarvelley
craigmarvelley / UISplitViewControllerDelegateService.m
Created September 27, 2014 21:56
Managing separation and collapsing of the new UISplitViewController in iOS 8
#import "UISplitViewControllerDelegateService.h"
#import "NoteViewController.h"
@interface UISplitViewControllerDelegateService () <UISplitViewControllerDelegate>
@end
@implementation UISplitViewControllerDelegateService
- (id)initWithSplitViewController:(UISplitViewController *)controller {
#import "AppDelegate.h"
@interface AppDelegate ()
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (strong, nonatomic) GCDWebServer *webServer;
@end
@implementation AppDelegate
#import "AppDelegate.h"
#import "AppCoordinator.h"
@interface AppDelegate ()
@property (strong, nonatomic) AppCoordinator *coordinator;
@end
@implementation AppDelegate
@implementation MyViewController
+ (BSInitializer *)bsInitializer {
return [BSInitializer initializerWithClass:self
selector:@selector(initWithApi:)
argumentKeys:@"myApi", nil];
}
- (instancetype)initWithApi:(MyApi *)myApi {
...
JSObjectionInjector *injector = [JSObjection createInjector];
[injector bindBlock:^(JSObjectionInjector *context) {
MyModel *model = [[MyModel alloc] initWithDependency:context.getObject([Dependency class])];
return model;
} toClass:[MyModel class]];
id myModel = [injector getObject:[MyModel class]];
@implementation ExampleAssembly
- (MyModel *)model {
return [TyphoonDefinition withClass:[MyModel class]
configuration:^(TyphoonDefinition* definition) {
[definition useInitializer:@selector(initWithDependency:)
parameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith:[self exampleDependency]];
@interface CoordinatorAssembly
@property (strong, nonatomic) DependencyOne *existingInjectedDependency;
- (DependencyTwo *)newDependency;
- (MyModel *)modelThatIsInjectedWithBothDependencies;
@end
- (void)showNoteSplitViewWithDataController:(DataController *)dataController searchController:(SearchController *)searchController {
NSParameterAssert(dataController);
NSParameterAssert(searchController);
NSString *authenticatedUserId = self.applicationSessionCredentialStore.userId;
NoteSplitViewAssembly *assembly = [self.assembly noteSplitViewAssemblyWithApplicationSession:self.applicationSession dataController:dataController searchController:searchController authenticatedUserId:authenticatedUserId];
[assembly activate];