This file contains hidden or 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
// add child view | |
UIViewController* controller = [self.storyboard instantiateViewControllerWithIdentifier:@"test"]; | |
[self addChildViewController:controller]; | |
controller.view.frame = CGRectMake(0, 44, 320, 320); | |
[self.view addSubview:controller.view]; | |
[controller didMoveToParentViewController:self]; | |
// remove child view | |
UIViewController *vc = [self.childViewControllers lastObject]; | |
[vc.view removeFromSuperview]; |
This file contains hidden or 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
extension String { | |
func md5() -> String! { | |
let str = self.cStringUsingEncoding(NSUTF8StringEncoding) | |
let strLen = CUnsignedInt(self.lengthOfBytesUsingEncoding(NSUTF8StringEncoding)) | |
let digestLen = Int(CC_MD5_DIGEST_LENGTH) | |
let result = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLen) | |
CC_MD5(str!, strLen, result) | |
var hash = NSMutableString() |
This file contains hidden or 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
(1) vim -b something.txt | |
(2) Escape | |
(3) :%s/^M//s | |
To avoid adding ^M in RubyMine or Web Storm, | |
Preference > General > Uncheck "Use soft wraps in editor" |
This file contains hidden or 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
=== cmake erros === | |
brew install mysql | |
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mysql-5.6.13.lion.bottle.tar.gz | |
######################################################################## 100.0% | |
Warning: Bottle installation failed: building from source. | |
Error: /usr/local/opt/cmake not present or broken | |
Please reinstall cmake. Sorry :( | |
=== Install cmake and then, mysql === | |
brew install cmake |
This file contains hidden or 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)startAnimation:(id)sender { | |
UIView animateWithDuration:2.0f delay:0.0f options:UIViewAnimationCurveEaseInOut animations:^{ | |
_yourView.alpha = 0.0f; | |
} completion:^(BOOL finished) { | |
// Do something | |
}]; | |
} | |
- (void)stopAnimation:(id)sender { | |
[UIView setAnimationBeginsFromCurrentState:YES]; |
This file contains hidden or 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
# in configs/application.rb | |
module MyApp | |
class Application < Rails::Application | |
config.autoload_paths += Dir["#{config.root}/lib"] | |
end | |
end |
This file contains hidden or 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
#author = Author.find(id) throws ActiveRecord::RecordNotFound error. | |
#for one record | |
author = Author.find_by_id(id) | |
if !author.nil? | |
#do something | |
else | |
#do something | |
end |
This file contains hidden or 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
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 32.0)]; | |
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(backHandler:)]; | |
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL]; | |
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | |
titleLabel.text = @"Sample Title"; | |
titleLabel.textAlignment = UITextAlignmentCenter; | |
titleLabel.backgroundColor = [UIColor clearColor]; |
This file contains hidden or 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
skip_before_filter :verify_authenticity_token ,:only=>[:action_name] |
This file contains hidden or 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
/* | |
References : | |
https://developers.facebook.com/docs/reference/api/photo/ | |
https://developers.facebook.com/docs/reference/api/privacy-parameter/ | |
*/ | |
// Upload Image | |
UIImage *uploadImage = /* assign your UIImage */ | |
//--- Post Parameters ---// |
NewerOlder