Skip to content

Instantly share code, notes, and snippets.

View romyilano's full-sized avatar
😎
improving

Romy romyilano

😎
improving
View GitHub Profile
@romyilano
romyilano / AppDelegate.m
Created February 1, 2014 17:06
grab a reference to the initial view controller while launching with a storyboard
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
return YES;
}
- (void)setupBackButtonWithSelector:(SEL)selector {
// create a custom button
LIButton *backButton = [LIButton buttonWithType:UIButtonTypeCustom];
backButton.positionInNavBar = LIButtonNavPositionLeft;
// more back button setup
// add back button to navigation bar
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backItem;
}
@romyilano
romyilano / AppDelegate.m
Last active August 29, 2015 13:57
changing color of the UINavigationController navbar shadowImage - i want the underline to be another color (like red or black). This doesn't quite work yet - any tips?
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// lots of stuff
// http://stackoverflow.com/questions/19101361/ios7-change-uinavigationbar-border-color/19102809#19102809
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
forBarMetrics:UIBarMetricsDefault];
@romyilano
romyilano / ViewController.m
Last active August 29, 2015 14:05
xcode storyboard... casting acrobatics.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIViewController *nextController = [segue destinationViewController];
if ([nextController isKindOfClass:[NewRunViewController class]]) {
// aha!
((NewRunViewController *)nextController).managedObjectContext = self.managedObjectContext;
}
}
@romyilano
romyilano / imagesquish.m
Created November 5, 2014 07:12
squishing 2 images on top of each other
- (IBAction)mergeImages:(id)sender {
UIImage *myFirstImage = [UIImage imageNamed:@"lemonface.png"];
UIImage *myTopImage = [UIImage imageNamed:@"crateKitty-holdingWater.png"];
CGFloat yFloat =10;
CGFloat xFloat = 10;
UIImage *newImage = [self placeImageOnImage:myFirstImage topImage:myTopImage x:xFloat y:yFloat];
[[self theNewImageView] setImage:newImage];
}
-(UIImage *)placeImageOnImage:(UIImage *)image topImage:(UIImage *)topImage
@romyilano
romyilano / mySnowboard.js
Last active August 29, 2015 14:11
javascript for dummies... nifty OOP similar behavior for javascript seen and heard on stackoverflow. it's like... it's not a class but you are like faking it til you making it. gNARLY http://stackoverflow.com/questions/1114024/constructors-in-javascript-objects
// is this standard????
var MySnowboard = (function () {
// private static
var serialNumber = 1;
// constructor without any vowels. why? just because. it's hip
var snwbrd = function () {
// private
var id = serialNumber++;
var name = 'Deep Moist Unknown';
@romyilano
romyilano / originators.js
Last active August 29, 2015 14:11
javascript closures. they are like objective-c blocks but... theyre uh closures. they are 1st class functiona. do javascript people care about memory? this is shocking. hmmm.
/*
http://www.javascriptkit.com/javatutors/closures.shtml
closure is the local variables for a function - kept alive AFTER the function hs returned
closure is a stack-frame which is not deallocaed when the function returns
wait... what? javascript has malloc? i thought it was fluffy. they care about memory management?
just kidding
*/
function sayOriginators(originalPlaya) {
var shoutOutScrawl = 'people dont know where it started where it came from but ' +
@romyilano
romyilano / snowboardHoarder.js
Last active August 29, 2015 14:11
how many snowboards is too many snowboards?
// how many snowboards is too many snowboards?
function SnowboardHoarder() {}
SnowboardHoarder.constructor = SnowboardHoarder //????
SnowboardHoarder.prototype.snowboardQuantity = function(currentNumberOwned) {
var finalNumber = 1;
if (currentNumberOwned == 0) {
finalNumber = 3;
} else {
finalNumber = currentNumberOwned + 1;
@romyilano
romyilano / ruffneck.js
Created December 21, 2014 07:17
MC Lyte Ruffneck. plus with all the relationship drama in hip hop, this is a positive but not fluffy song..t https://www.youtube.com/watch?v=ygteZWP_tL0 making learning javascript less scary for an objective-c programmer. just kidding! we love javascript
// http://www.phpied.com/3-ways-to-define-a-javascript-class/
// so javascript doesn't really have classes but dictionaries
// but you can fake classes?
// methods added to the prototype
function Ruffneck () {
this.gender = "man";
this.shoes = "Timberlands";
this.hair = "shaved";
}
@romyilano
romyilano / skateboardtricks.js
Created December 24, 2014 01:31
skateboard tricks that made it to snowboarding - javascript "class like" prototype -- 8D
#import "Skateboard.js"
function Snowboard() {}
// this is how it inherits from another instance
Snowboard.prototype = new Skateboard();
Snowboard.constructor = Snowboard
// pushing a dictionary in javascript???
Snowboard.prototype.tricks = function () {
// could this be done without a function???