Skip to content

Instantly share code, notes, and snippets.

View myell0w's full-sized avatar
🙌

Matthias Tretter myell0w

🙌
View GitHub Profile
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
@samvermette
samvermette / gist:1691280
Created January 27, 2012 22:27
MapKit callout bubble pop animation
self.view.layer.anchorPoint = CGPointMake(0.50, 1.0);
CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
bounceAnimation.values = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.05],
[NSNumber numberWithFloat:1.08],
[NSNumber numberWithFloat:0.92],
[NSNumber numberWithFloat:1.0],
nil];
@zwaldowski
zwaldowski / DZRoundProgressView.h
Created February 5, 2012 16:48
Layer-backed pie progress view
@interface DZRoundProgressView : UIView
@property (nonatomic) CGFloat progress;
- (void)setProgress:(CGFloat)progress animated:(BOOL)animated;
@end
@nielsbot
nielsbot / UIImage+JPEG2000.h
Created February 19, 2012 00:43
Decoding JPEG 2000 files to UIImage
#import <Foundation/Foundation.h>
extern UIImage * UIImageWithJPEG2000Data( NSData * data ) ;
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jonsterling
jonsterling / Example.m
Created May 13, 2012 02:55
Safe keypaths without macros!
NSString *safe = self.keys.url.port.stringValue;
NSString *unsafe = @"url.port.stringValue";
assert([safe isEqualToString:unsafe]);
@odrobnik
odrobnik / gist:2872435
Created June 5, 2012 03:25
Inner Shadow on Label
- (void)drawTextInRect:(CGRect)rect
{
[super drawTextInRect:rect];
CGContextRef ctx = UIGraphicsGetCurrentContext();
NSString *fontName = self.font.fontName;
CGFloat fontSize = self.font.pointSize;
CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)fontName, fontSize, NULL);
//
// NSString+Cheddar.m
// Cheddar
//
// Created by Sam Soffes on 6/10/12.
// Copyright (c) 2012 Nothing Magical. All rights reserved.
//
#import "NSString+Cheddar.h"
@steipete
steipete / gist:3933090
Created October 22, 2012 18:13
Simple main thread usage detector that I'm using in PSPDFKit to find performance problems early on.
// Smart little helper to find main thread hangs. Enable in appDidFinishLaunching.
// Only available with source code in DEBUG mode.
@interface PSPDFHangDetector : NSObject
+ (void)startHangDetector;
@end
@implementation PSPDFHangDetector
+ (void)startHangDetector {
#ifdef DEBUG
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
const CGFloat threshHold = -60.0f;
const float minOpacity = 0.2;
CGFloat currentOffset = [scrollView contentOffset].x;
if (currentOffset < 0.0)
{
CGFloat currentProgress = currentOffset / threshHold;
[scrollView setAlpha:MAX(1.0 - (1.0 * currentProgress), minOpacity)];