Skip to content

Instantly share code, notes, and snippets.

View dlinsin's full-sized avatar

David Linsin dlinsin

View GitHub Profile
static <T,U> List<U> map(List<T> list,{T=>U} transform) {
List<U> result = new ArrayList<U>(list.size());
for (T t : list) { result.add(transform.invoke(t)); }
return result;
}
public static void main(String[] args) {
List<Color> colors = map(Arrays.asList(Flavor.values()), { Flavor f => f.color });
System.out.println(colors.equals(Arrays.asList(Color.values())));
}
public Issue browse(Repository argRepository, int argIssueNo) {
RestTemplate template = new RestTemplate();
template.setMessageConverters(new HttpMessageConverter[] {
new MappingJacksonHttpMessageConverter()});
IssueResponse resp = template.getForObject(BASE_URL + "issues/show/{username}/{repo}/{no}", IssueResponse.class,
argRepository.getOwner(), argRepository.getName(), String.valueOf(argIssueNo));
return resp.getIssue();
}
public class IssueResponse {
private Issue issue;
public Issue getIssue() {
return issue;
}
public void setIssue(Issue argIssue) {
issue = argIssue;
}
}
{"issue":
{"number":1,"votes":0,"created_at":"2009/11/01 07:27:56 -0800",
"body":"This is a sample issue! Used in my RestTemplateSample!",
"title":"Sample Issue",
"updated_at":"2009/11/01 09:16:58 -0800","closed_at":null,
"user":"dlinsin","labels":["minor"],"state":"open"
}
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
tableViewNavigationBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)];
UIImage *image = [UIImage imageNamed:@"synyx_150_no_os.png"];
imageView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(84.0, 1.0, image.size.width, image.size.height) ];
[imageView setImage:image];
[tableViewNavigationBar addSubview:imageView];
//
// RouteController.m
// synyx
//
// Created by David Linsin on 10/12/09.
// Copyright 2010 Synyx GmbH & Co. KG. All rights reserved.
//
#import "RouteController.h"
#import "NSObject+YAJL.h"
NSDictionary *vals = [jsonResponse yajl_JSON];
[player fill:vals];
- (void)fill:(NSDictionary *)vals {
NSString *key;
for (key in vals) {
[self setValue:[vals objectForKey:key] forKey:key];
}
- (id)initWithParent:(UIView *)parent {
self = [self initWithFrame:CGRectZero];
if (!self)
return nil;
[parent addSubview:self];
return self;
}
+ (id) viewWithParent:(UIView *)parent {
return [[[self alloc] initWithParent:parent] autorelease];
}
@synthesize pageIndex = _pageIndex;
- (id) initWithParent:(UIView *)parent {
self = [super initWithParent:parent];
if (self == nil) {
return nil;
}
self.userInteractionEnabled = YES;
self.size = self.window.size;
[[UIImageView viewWithParent:self] setImageWithName:@"dailies"];
// Person.h
@interface Person {
NSString *name;
}
@property (retain) NSString *name;
@end