Skip to content

Instantly share code, notes, and snippets.

View is8r's full-sized avatar
🙂

Yu Ishihara is8r

🙂
View GitHub Profile
@is8r
is8r / gist:5787713
Created June 15, 2013 10:41
UINavigationBarを隠したり登場させたりする
[self.navigationController setNavigationBarHidden:YES animated:YES];
@is8r
is8r / gist:5787773
Created June 15, 2013 11:08
TableViewCellの高さを可変にする
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
CGSize size = [cell.textLabel.text sizeWithFont:cell.textLabel.font constrainedToSize:tableView.frame.size lineBreakMode:UILineBreakModeWordWrap];
return size.height;
}
@is8r
is8r / gist:5797061
Last active December 18, 2015 14:28
NSMutableArrayを格納されているNSDictionaryの値を使ってソートする
//sortNSMutableArray(array, attr);
static inline NSMutableArray *sortNSMutableArray(NSMutableArray *ar, NSString *attr) {
NSSortDescriptor *dateAsc = [[[NSSortDescriptor alloc] initWithKey:attr ascending:NO] autorelease];
NSMutableArray *descriptors = [NSArray arrayWithObjects:dateAsc, nil];
[ar sortUsingDescriptors:descriptors];
return ar;
}
@is8r
is8r / new_gist_file
Created June 20, 2013 03:05
link_toにクラスを指定
= link_to "xxx", "#", :class => ["active"]
= link_to "xxx", "#", {:class => "active"}
@is8r
is8r / gist:5855992
Last active December 18, 2015 22:39
NSDateを渡して現在の時間との時間差を求める
//NSDateを渡して現在の時間との時間差を求める
//getTiming(date);
static inline NSString* getTiming(NSDate *date) {
NSDateFormatter *dateFormatter = [NSDateFormatter new];
[dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"ja_JP"]];
[dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
NSString *sdate = [dateFormatter stringFromDate:date];
NSDate *now = [NSDate dateWithTimeIntervalSinceNow:[[NSTimeZone systemTimeZone] secondsFromGMT]];
NSTimeInterval since = [now timeIntervalSinceDate:date];
int day = since/(24*60*60);
@is8r
is8r / gist:5857463
Last active December 18, 2015 22:49
NSMutableDictionaryのモダンな書き方
NSMutableDictionary *dic = @{
@"xxx":xxx,
@"xxxx":xxxx
}.mutableCopy;
//or
NSMutableDictionary *dic = @{}.mutableCopy;
dic[@"xxx"] = @"xxx";
dic[@"xxxx"] = @"xxxx";
@is8r
is8r / gist:5857504
Last active December 18, 2015 22:49
NSMutableArrayのモダンな書き方
NSMutableArray *ar = @[
@"xxx",
@"xxxx"
].mutableCopy;
NSMutableArray *ar = @[].mutableCopy;
ar[0] = @"xxx";
ar[1] = @"xxxx";
@is8r
is8r / new_gist_file
Created June 26, 2013 03:01
一番近い要素を取得
$(e.target).closest('li')
@is8r
is8r / gist:5864706
Last active December 18, 2015 23:49
for文
for p in ar
console.log p
@is8r
is8r / gist:5867777
Created June 26, 2013 14:25
関数を遅延させて実行
// 遅延
[self performSelector:@selector(onDelay) withObject:nil afterDelay:11.0];
// 遅延(引数有り)
[self performSelector:@selector(onDelay:) withObject:@(10) afterDelay:1.0];
- (void)onDelay
{
NSLog(@"onDelay");
}