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
private var keyboardInputView: UIToolbar { | |
let toolbar = UIToolbar(frame: CGRectMake(0, 0, self.view.frame.size.width, 44)) | |
let completeItem = UIBarButtonItem(title: "完了", style: .Done, target: self, action: "completeEditing:") | |
let space = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil) | |
toolbar.items = [space, completeItem] | |
return toolbar | |
} |
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
func currentPageIndex(#maxPageIndex: Int) -> Int { | |
let w: CGFloat = CGRectGetWidth(self.frame) | |
let x: CGFloat = self.contentOffset.x | |
var index: Int = Int(round(x / w)) | |
if index < 0 { | |
index = 0 | |
} else if index > maxPageIndex { | |
index = maxPageIndex | |
} |
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
override func viewWillAppear(animated: Bool) { | |
super.viewWillAppear(animated) | |
NSNotificationCenter.defaultCenter().addObserver(self, | |
selector: "keyboardWillShow:", | |
name: UIKeyboardWillShowNotification, | |
object: nil) | |
NSNotificationCenter.defaultCenter().addObserver(self, | |
selector: "keyboardWillHide:", | |
name: UIKeyboardWillHideNotification, |
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
import UIKit | |
extension CALayer { | |
func setBorderColorFromUIColor(color: UIColor) { | |
self.borderColor = color.CGColor | |
} | |
} |
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
+ (instancetype)builder:(MyClass * (^)(MyClass *obj))buildHandler | |
{ | |
MyClass *obj = [MyClass new]; | |
return buildHandler(obj); | |
} |
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
#import "NSDate+String.h" | |
@implementation NSDate (String) | |
- (NSString *)stringValue | |
{ | |
NSDateFormatter *fm = [[NSDateFormatter alloc] init]; | |
[fm setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; | |
NSString *str = [fm stringFromDate:self]; | |
[fm release]; |
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)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
// キーボード表示・非表示イベント | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification | |
object: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
#!/usr/bin/ruby | |
days = Hash::new | |
if ARGV[0].nil? | |
# get latest file name | |
file_names = Dir::glob(File.expand_path("~/Dropbox/Tasks/*.md")).sort{|x, y| y <=> x} | |
target_file_name = file_names[0] | |
else | |
# get selected file name |
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
NSArray *array = @[@"北海道", | |
@"青森県", | |
@"岩手県", | |
@"宮城県", | |
@"秋田県", | |
@"山形県", | |
@"福島県", | |
@"茨城県", | |
@"栃木県", | |
@"群馬県", |
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
$prefNames = array( | |
'北海道', | |
'青森県', | |
'岩手県', | |
'宮城県', | |
'秋田県', | |
'山形県', | |
'福島県', | |
'茨城県', | |
'栃木県', |