Skip to content

Instantly share code, notes, and snippets.

@phildow
phildow / CLLocation+EXIFGPS.h
Last active December 2, 2019 02:37
Category to create GPS metadata dictionary from CLLocation and CLHeading for writing to EXIF data in images.
#import <CoreLocation/CoreLocation.h>
#import <ImageIO/ImageIO.h>
@interface CLLocation (EXIFGPS)
- (NSDictionary*) EXIFMetadataWithHeading:(CLHeading*)heading;
@end
@interface NSDate (EXIFGPS)
@rnystrom
rnystrom / gist:5052675
Created February 27, 2013 23:04
Masking a chip out of a UIView.
- (void)maskChip {
UIGraphicsBeginImageContextWithOptions(self.containerView.bounds.size, NO, [UIScreen mainScreen].scale);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect frame = self.containerView.bounds;
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, frame.size.width / 2.f - 6, 0);
CGPathAddLineToPoint(path, NULL, frame.size.width / 2.f, 6);
CGPathAddLineToPoint(path, NULL, frame.size.width / 2.f + 6, 0);
@jder
jder / Downscaling ALAssets
Last active March 20, 2018 06:51
A method for downscaling ALAssets
// For details, see http://mindsea.com/2012/12/18/downscaling-huge-alassets-without-fear-of-sigkill
#import <AssetsLibrary/AssetsLibrary.h>
#import <ImageIO/ImageIO.h>
// Helper methods for thumbnailForAsset:maxPixelSize:
static size_t getAssetBytesCallback(void *info, void *buffer, off_t position, size_t count) {
ALAssetRepresentation *rep = (__bridge id)info;
NSError *error = nil;
@nfarina
nfarina / UIView+FrameAdditions.h
Created August 21, 2012 06:40
UIView Frame helper getter/setter category methods
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end
@rgerard
rgerard / NSString+Additions.h
Created July 16, 2012 00:40
NSString category that returns an NSNumber with the correct ordinal ending. This was borrowed from http://stackoverflow.com/questions/3312935/nsnumberformatter-and-th-st-nd-rd-ordinal-number-endings
#import <Foundation/Foundation.h>
@interface NSString (Additions)
+ (NSString*)ordinalNumberFormat:(NSNumber *)numObj;
@end
@erans
erans / UIImage+Resize.m
Created November 7, 2011 07:10
UIImage+Resize.m Fix for Rotation / Orientation on iOS 5
- (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality {
BOOL drawTransposed;
CGAffineTransform transform = CGAffineTransformIdentity;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
// Apprently in iOS 5 the image is already correctly rotated, so we don't need to rotate it manually
drawTransposed = NO;
} else {
switch (self.imageOrientation) {
case UIImageOrientationLeft:
@akisute
akisute / gist:1141953
Created August 12, 2011 12:41
Create an animated gif file from images in iOS
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
- (void)exportAnimatedGif
{
UIImage *shacho = [UIImage imageNamed:@"shacho.png"];
UIImage *bucho = [UIImage imageNamed:@"bucho.jpeg"];
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"animated.gif"];

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@zoul
zoul / AVAssetExportSession+Testing.m
Created November 8, 2010 08:35
Export assets synchronously. Good for testing.
@implementation AVAssetExportSession (Testing)
- (void) exportSynchronously
{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[self exportAsynchronouslyWithCompletionHandler:^{
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);