Skip to content

Instantly share code, notes, and snippets.

View muukii's full-sized avatar
✈️
We live in a twilight world.

Hiroshi Kimura muukii

✈️
We live in a twilight world.
View GitHub Profile
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 April 12, 2014 07:44
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 August 29, 2015 13:59
UIColleciton-TableView ReloadData
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 August 29, 2015 14:00
NSFetchedResultsControllerDelegate with UICollectionView
- (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 12:42
Here are some things you can do with Gists in GistBox.
// 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 August 29, 2015 14:01
Python 全ファイル表示
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 July 19, 2014 10:00
Autolayout : UITableViewCell : size
+ (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 August 29, 2015 14:04
先頭にアイコンを付けた文字列で、アイコンの縦位置がずれる場合の調整
[mutableAttributedString addAttribute:NSBaselineOffsetAttributeName
value:@(-1.)
range:NSMakeRange(0, 1)];
<!-- 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 August 29, 2015 14:06
Swift NSFetchedResultsController
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