Skip to content

Instantly share code, notes, and snippets.

View justincbeck's full-sized avatar

Justin C. Beck justincbeck

  • BeckProduct LLC
  • Crozet, VA
View GitHub Profile
CALayer *mask = [CALayer layer];
mask.contents = (id)[[UIImage imageNamed:@"student_image_mask"] CGImage];
mask.frame = CGRectMake(0, 0, 80, 80);
[imgView.layer setCornerRadius:40.0];
[imgView.layer setBorderColor:[UIColor whiteColor].CGColor];
[imgView.layer setBorderWidth:3.0];
[imgView setBackgroundColor:[UIColor colorWithWhite:220.0/255.0 alpha:1.0]];
imgView.layer.mask = mask;
@justincbeck
justincbeck / gist:9938588
Created April 2, 2014 17:13
Presenting Modal VC
_assessmentListViewController = [[PMAssessmentListViewController alloc] initWithNibName:@"PMAssessmentListViewController" bundle:[NSBundle mainBundle]];
[_assessmentListViewController setStudent:student];
[_assessmentListViewController setAssessment:[[student classroom] assessment]];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:_assessmentListViewController];
[navController setDelegate:self];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"done" style:UIBarButtonItemStylePlain target:self action:@selector(dismissTaskList:)];
[[_assessmentListViewController navigationItem] setLeftBarButtonItem:doneButton];
@justincbeck
justincbeck / gist:9938574
Created April 2, 2014 17:12
AppDelegate - Setting the appearance proxies for UIBarButtonItems
// UIBarButtonItem Appearance
NSMutableDictionary *barButtonItemAttributes = [NSMutableDictionary dictionary];
[barButtonItemAttributes setValue:[UIFont fontWithName:@"AvenirNextCondensed-Regular" size:20.0] forKey:NSFontAttributeName];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemAttributes forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonItemAttributes forState:UIControlStateHighlighted];
@justincbeck
justincbeck / gist:4723077
Created February 6, 2013 14:57
Add a shadow to a view...
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo"]];
self.navigationItem.titleView = imageView;
[imageView setClipsToBounds:NO];
imageView.layer.shadowOffset = CGSizeMake(4.0f, 4.0f);
imageView.layer.shadowOpacity = 1.0f;
imageView.layer.shadowColor = [UIColor blackColor].CGColor;
@justincbeck
justincbeck / gist:4061693
Created November 12, 2012 20:32
ContainerViewController
//============ AppDelegate ===============
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
NSMutableArray *controllers = [NSMutableArray array];
@justincbeck
justincbeck / gist:1783723
Created February 9, 2012 22:14
Drop a commit
# git rebase -i head~n (where n is the number of commits from head you want)
# You will see something like this:
pick 907cdd8 Added new files to project
pick 8be0e96 Recent profile view pull to reload
# Rebase a1cd6ef..8be0e96 onto a1cd6ef
#
# Commands:
@justincbeck
justincbeck / gist:1618855
Created January 16, 2012 03:16
Pointers and address space
// Assume array is an NSArray of NSString objects
NSString *lastFoo = nil;
for (NSString *foo in array)
{
lastFoo = foo; // Why doesn't foo take on the address of bar?
lastFoo = &foo; // Is this better?
*lastFoo = &foo; // Or perhaps this?
// Other suggestions?
@justincbeck
justincbeck / gist:1219065
Created September 15, 2011 11:49
Ruby, or is it?
Factorial = (n) {
(y,f) { y.(f).(n) }.(
(le) {
(f) { f.(f) }.(
(f) {
le.(->(x) { f.(f).(x) })
})
},
(recurse) {
(n) { (n==0) ? 1 : n * recurse.(n-1) }