This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myLabel.textColor = [UIColor whiteColor]; | |
myLabel.font = [UIFont systemFontOfSize:14]; | |
myLabel.textAlignment = NSTextAlignmentCenter; | |
myLabel.adjustsFontSizeToFitWidth = YES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *jsonFileName =@"your-json-file-name"; | |
NSString *filePath = [[NSBundle mainBundle] pathForResource:jsonFileName ofType:@"json"]; | |
NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:nil]; | |
NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSData *passData = [keychain objectForKey:(id)kSecValueData]; | |
NSString *pass = [[NSString alloc] initWithBytes:[passData bytes] length:[passData length] encoding:NSUTF8StringEncoding]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function set_ruby2_with_gemset(){ | |
local result=${PWD##*/} | |
local result=${result// /_} | |
local result=$(echo $result | tr '[A-Z]' '[a-z]') | |
echo "prepare ruby 2.0 with gemset "$result | |
rvm --create ruby-2.0.0-p247@$result | |
} | |
function use_ruby2_with_gemset(){ | |
local result=${PWD##*/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function set_ruby2_with_gemset(){ | |
local result=${PWD##*/} | |
local result=${result// /_} | |
local result=$(echo $result | tr '[A-Z]' '[a-z]') | |
echo "prepare ruby 2.0 with gemset "$result | |
rvm --create ruby-2.0.0-p247@$result | |
} | |
function use_ruby2_with_gemset(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Rails time to NSdate | |
NSDateFormatter *df = [[NSDateFormatter alloc] init]; | |
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZ"]; | |
NSDate *date = [df dateFromString:@"2013-04-07T21:19:14Z"]; | |
//NSDate to String | |
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
[formatter setDateFormat:@"MM/dd/yyyy HH:mm a"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
File: KeychainItemWrapper.h | |
Abstract: | |
Objective-C wrapper for accessing a single keychain item. | |
Version: 1.2 - ARCified | |
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple | |
Inc. ("Apple") in consideration of your agreement to the following | |
terms, and your use, installation, modification or redistribution of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)preparePulltoRefresh{ | |
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; | |
refreshControl.tintColor = [UIColor whiteColor]; | |
[refreshControl addTarget:self action:@selector(reloadMeetings) forControlEvents:UIControlEventValueChanged]; | |
//creating view for extending background color | |
CGRect frame = self.tableView.bounds; | |
frame.origin.y = -frame.size.height; | |
UIView *refreshBackgroundView = [[UIView alloc]initWithFrame:frame]; | |
refreshBackgroundView.backgroundColor = UIColorFromRGB(0xXXXXXX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)viewDidLayoutSubviews | |
{ [super viewDidLayoutSubviews]; | |
dispatch_queue_t imageReader = dispatch_queue_create("Image Reader", NULL); | |
dispatch_async(imageReader, ^{ | |
[NSThread sleepForTimeInterval:1]; | |
UIImage *image = [UIImage imageNamed:self.imageName]; // may take time to load | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
self.imageView.image = image; | |
self.imageView.contentMode = UIViewContentModeTopLeft; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#devise/cookie_token_auth_strategy | |
module CookieTokenAuthStrategy | |
Warden::Strategies.add(:token_cookie_strategy) do | |
def valid? | |
token_from_cookie | |
end | |
def authenticate! | |
if token_from_cookie.present? && (user = User.find_for_token_authentication(:auth_token => token_from_cookie)).present? | |
delete_token_from_cookie |