Skip to content

Instantly share code, notes, and snippets.

Avatar
✈️
We live in a twilight world.

Hiroshi Kimura muukii

✈️
We live in a twilight world.
View GitHub Profile
View Fast Rendering
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.window.screen.scale);
[self.imageView drawViewHierarchyInRect:self.frame afterScreenUpdates:YES];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@muukii
muukii / iOS7 default animation
Created Apr 12, 2014
iOS7 default animation
View iOS7 default animation
[UIView animateWithDuration:0.5f delay:0 usingSpringWithDamping:1 initialSpringVelocity:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//animation
} completion:^(BOOL finished) {
//completion
}];
@muukii
muukii / gist:10703171
Last active Aug 29, 2015
UIColleciton-TableView ReloadData
View gist:10703171
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFade];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[animation setFillMode:kCAFillModeBoth];
[animation setDuration:.05];
[collectionView.layer addAnimation:animation forKey:kCATransition];
@muukii
muukii / gist:ca28e3c96b76d3c6cf18
Last active Aug 29, 2015
NSFetchedResultsControllerDelegate with UICollectionView
View gist:ca28e3c96b76d3c6cf18
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
self.blockOperation = [[NSBlockOperation alloc] init];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
__block UICollectionView *collectionView = self.collectionView;
switch (type) {
case NSFetchedResultsChangeInsert: {
@muukii
muukii / 0_reuse_code.js
Created May 23, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@muukii
muukii / gist:a50c0cfbe4931016145b
Last active Aug 29, 2015
Python 全ファイル表示
View gist:a50c0cfbe4931016145b
def findAllFiles(path):
for root, dirs, files in os.walk(os.path.expanduser(path)):
yield root
for file in files:
yield os.path.join(root, file)
for file in findAllFiles(''):
print (file)
@muukii
muukii / gist:d818a80e7fb0ab176c63
Created Jul 19, 2014
Autolayout : UITableViewCell : size
View gist:d818a80e7fb0ab176c63
+ (CGFloat)heightOfCellWithTableView:(UITableView *)tableView obj:(id)obj
{
static MMCell *sizingCell = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sizingCell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
});
sizingCell.obj = obj;
CGSize size = [sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height;
@muukii
muukii / gist:1bc878babe2be43178f9
Last active Aug 29, 2015
先頭にアイコンを付けた文字列で、アイコンの縦位置がずれる場合の調整
View gist:1bc878babe2be43178f9
[mutableAttributedString addAttribute:NSBaselineOffsetAttributeName
value:@(-1.)
range:NSMakeRange(0, 1)];
View gist:55dde31bf11c13ad7ccd
<!-- Code syntax highlight -->
<link href="http://static.tumblr.com/7ugkukk/n2bn9udeb/tomorrow-night.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript " src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
<script type="text/javascript">
$(function(){
var code = $('code');
code.replaceWith('<pre>'+code.text()+'</pre>');
$('pre').css({
'overflow-x': 'scroll',
@muukii
muukii / gist:4c6322afdfe24e6adf96
Last active Aug 29, 2015
Swift NSFetchedResultsController
View gist:4c6322afdfe24e6adf96
var fetchedResultsController: NSFetchedResultsController {
if _fetchedResultsController != nil {
return _fetchedResultsController!
}
let fetchRequest = NSFetchRequest()
// Edit the entity name as appropriate.
let entity = NSEntityDescription.entityForName(CPCommentObject.entityName(), inManagedObjectContext: NSManagedObjectContext.managedObjectContextForMainThread())
fetchRequest.entity = entity