Skip to content

Instantly share code, notes, and snippets.

View sebastienwindal's full-sized avatar

Sebastien Windal sebastienwindal

View GitHub Profile
@sebastienwindal
sebastienwindal / gist:ab02e7dffee942f016194cf08b39ec56
Created February 9, 2017 00:22
find biggest image assets in your iOS app...
du -ah | egrep -v "AppStore|DerivedData|Pods|Frameworks" | egrep -i "PNG|jp(e?)g" | sort -n -r | more
@sebastienwindal
sebastienwindal / .block
Last active February 24, 2016 16:40 — forked from mbostock/.block
Calendar View
license: gpl-3.0
height: 910
border: no
@sebastienwindal
sebastienwindal / JNWThrottledBlock.h
Created October 6, 2015 22:28 — forked from jwilling/JNWThrottledBlock.h
Simple throttling of blocks using dispatch sources.
#import <Foundation/Foundation.h>
@interface JNWThrottledBlock : NSObject
// Runs the block after the buffer time _only_ if another call with the same identifier is not received
// within the buffer time. If a new call is received within that time period the buffer will be reset.
// The block will be run on the main queue.
//
// Identifier and block must not be nil.
+ (void)runBlock:(void (^)())block withIdentifier:(NSString *)identifier throttle:(CFTimeInterval)bufferTime;
YapDatabaseViewGroupingWithObjectBlock groupingBlock = ^NSString *(NSString *collection, NSString *key, id object) {
if (![object isKindOfClass:[MealLogRemote class]]) {
return nil;
}
return "all"; // we only need one section/group in this case
};
YapDatabaseViewSortingWithObjectBlock sortingBlock = ^NSComparisonResult (NSString *group, NSString *collection1, NSString *key1, MealLogRemote *obj1,
NSString *collection2, NSString *key2, MealLogRemote *obj2){
// we don't need sorting but this using a sorting for a view is mandatory, lets sort it by date
@sebastienwindal
sebastienwindal / gist:5d747672af966d4b6d83
Last active August 29, 2015 14:20
Core Data Sample
// delete all placeholder meal logs older than a certain date
NSPredicate *oldPlaceholderPredicate = [NSPredicate predicateWithFormat:@"(isPlaceholderMealLog = TRUE) AND (eatenOn < %@)", twoDaysAgoAtMidnight];
[MealLogManaged MR_deleteAllMatchingPredicate:oldPlaceholderPredicate inContext:context];
@sebastienwindal
sebastienwindal / gist:0f2de5c4504ccd4473d5
Last active August 29, 2015 14:17
animate auto-layout
self.myConstraint.constant = 1234;
[UIView animateWithDuration:0.3 animations:^{
[self.someview layoutIfNeeded];
}];
/*
File: UIImage+ImageEffects.m
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
/*
File: UIImage+ImageEffects.h
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
// .h file
@interface LessonManager : NSObject
@property (strong, nonatomic) NSString * imageTitle;
+ (instancetype) sharedInstance;
@end
@sebastienwindal
sebastienwindal / keyboard handling in iOS
Last active August 29, 2015 14:00
Make a whole view scroll up to make the control appear when keyboard shows up. self.rootScrollView is a scrollview that stretches in the whole screen.
- (void)observeKeyboard
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)stopObservingKeyboard
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];