Skip to content

Instantly share code, notes, and snippets.

View isutton's full-sized avatar

Igor Sutton isutton

  • Lemonade
  • Amsterdam
View GitHub Profile
@isutton
isutton / example.go
Last active August 29, 2019 13:44
Watch from Mapper example
type CRDToWatchMapper {
c *Controller
}
func (m *CRDToWatchMapper) Map(obj handler.MapObject) []reconcile.Request {
crdGvk := extractGVKFromCRD(obj.Object)
m.c.Watch(
createSourceForGVK(crdGvk),
&handler.EnqueueRequestsFromMapFunc{ToRequests: &SBRRequestMapper{}},
)
apiVersion: shipper.booking.com/v1alpha1
kind: CapacityTarget
metadata:
creationTimestamp: 2019-02-12T15:43:39Z
generation: 1
labels:
shipper-app: reviews-api
shipper-release: reviews-api-fba08f42-0
shipper-release-hash: fba08f42
  • staging/src/k8s.io/apiserver/pkg/server/options/admission.go:143
genericInitializer := initializer.New(clientset, informers, c.Authorization.Authorizer, scheme)
  • vendor/k8s.io/apiserver/pkg/admission/initializer/initializer.go:65
package Server;
sub process {
my ( $check_name ) = @_;
my $reactor = Reactor->new;
my $callback = $server->callback_for( 'my_check' );
# Callback popula $reactor através da interface estipulada.
(defadvice gnus-summary-reply (after my-gnus-summary-reply (&optional yank wide very-wide))
"My gnus-summary-reply advice"
(forward-visible-line 2))
(ad-activate 'gnus-summary-reply)
@isutton
isutton / Example.m
Created November 27, 2013 16:02
NSOperation dependency creep
NSMutableDictionary *context = [NSMutableDictionary dictionary];
// Adds information in context under the key "fromOp1"
Op1 *op1 = [[Op1 alloc] initWithContext:context];
// Consumes "fromOp1" from context and add info under the key "fromOp2"
Op2 *op2 = [[Op2 alloc] initWithContext:context];
[op2 addDependency:op1];
@isutton
isutton / gist:5066265
Created March 1, 2013 17:27
`valueForKeyPath` example
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSArray *array = @[
@{@"name": @"Igor"},
@{@"name": @"Tom"},
@{@"name": @"Matt"},
@{@"name": @"Mike"}
];
@isutton
isutton / MyWindow.h
Created October 25, 2012 09:21
UIWindow subclass that adds rounded top corners.
@interface MyWindow : UIWindow
@end
@isutton
isutton / LoginHandler.h
Created July 19, 2012 21:11
Alert Pattern for Cocoa Touch
typedef enum {
LoginHandlerConnectionError,
LoginHandlerInvalidCredentialsError,
LoginHandlerUnknownError
} LoginHandlerError;
typedef enum {
LoginHandlerDismissAction,
LoginHandlerRetryAction
} LoginHandlerAction;
@isutton
isutton / gist:3075958
Created July 9, 2012 11:33
NSInvocation usage example.
// Omitting the ownership qualification here can lead to a EXC_BAD_ACCESS exception in ARC enabled projects.
__weak id returnValue = nil;
SEL selector = @selector(colorFromString:);
NSString *valueString = @"0.2 0.2 0.2 1.0";
// Create and configure the NSInvocation object.
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[target methodSignatureForSelector:selector]];
invocation.selector = selector;
invocation.target = target;