Skip to content

Instantly share code, notes, and snippets.

View autresphere's full-sized avatar

Philippe Converset autresphere

View GitHub Profile
@autresphere
autresphere / gist:037759fa29697d46ff43
Created May 20, 2015 14:40
Exporting an IPA with xcodebuild from an archive.
xcodebuild -exportArchive -archivePath $projectname.xcarchive -exportPath $projectname -exportFormat ipa -exportProvisioningProfile “Provisioning Profile Name”
@autresphere
autresphere / LoopingVideoViewSkeleton
Created May 20, 2015 10:07
Skeleton to create a looping video view.
#import "MyViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface MyViewController ()
@property (strong, nonatomic) IBOutlet UIView *movieView;
@property (strong, nonatomic) AVPlayer *player;
@end
@implementation MyViewController
@autresphere
autresphere / gist:7752157
Created December 2, 2013 16:29
Screenshot
- (UIImage*)screenshot
{
// Create a graphics context with the target size
// On iOS 4 and later, use UIGraphicsBeginImageContextWithOptions to take the scale into consideration
// On iOS prior to 4, fall back to use UIGraphicsBeginImageContext
CGSize imageSize = [[UIScreen mainScreen] bounds].size;
if (NULL != UIGraphicsBeginImageContextWithOptions)
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
else
UIGraphicsBeginImageContext(imageSize);
@autresphere
autresphere / gist:5831661
Created June 21, 2013 14:45
iOS showFonts
- (void)showFonts
{
NSArray *familyNames = [UIFont familyNames];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]];
@autresphere
autresphere / gist:5807401
Created June 18, 2013 17:18
Xcode comment to print out request body
po [[NSString alloc] initWithData:[request HTTPBody] encoding:4]
@autresphere
autresphere / gist:5494101
Last active December 16, 2015 20:39
TODO & FIXME warnings excluding external libs
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" -ipath "${SRCROOT}/pods" -prune -o \( -name "*.h" -or -name "*.m" \) -not -path "${SRCROOT}/Libs/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
@autresphere
autresphere / gist:5489099
Created April 30, 2013 14:29
Retrieves the size of a video from its path.
+ (CGSize)sizeOfVideoAtPath:(NSString *)path
{
NSURL *url;
AVAsset *asset;
NSArray *tracks;
url = [NSURL fileURLWithPath:path];
asset = [[AVURLAsset alloc] initWithURL:url options:nil];
tracks = [asset tracksWithMediaType:AVMediaTypeVideo];
if(tracks != nil)
@autresphere
autresphere / gist:5300529
Created April 3, 2013 11:49
How to handle view controller transitions with an animated: flag (http://khanlou.com/2013/03/animations-with-an-animated-flag/). Another solution much simpler.
- (void) pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
newViewController.view.frame = //original frame
[self addChildViewController:newViewController];
[self transitionFromViewController:oldViewController
toViewController:newViewController
duration:(animated?0.35f:0)
options:0
animations:^{