Skip to content

Instantly share code, notes, and snippets.

View atnan's full-sized avatar

Nathan de Vries atnan

View GitHub Profile
@atnan
atnan / gist:997780
Created May 29, 2011 13:28
Fading view transition...
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionFade;
transition.duration = animated ? 0.5f : 0.0f;
transition.fillMode = kCAFillModeForwards;
transition.removedOnCompletion = YES;
[[UIApplication sharedApplication].keyWindow.layer addAnimation:transition forKey:@"transition"];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
@atnan
atnan / AvailabilityInternal.h
Created May 25, 2011 00:32
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/include/AvailabilityInternal.h
/*
* Copyright (c) 2007-2010 by Apple Inc.. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
@atnan
atnan / gist:961388
Created May 8, 2011 13:51
Simulate memory warning
- (void)simulateMemoryWarning {
#if TARGET_IPHONE_SIMULATOR
#ifdef DEBUG
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (CFStringRef)@"UISimulatedMemoryWarningNotification", NULL, NULL, true);
#endif
#endif
}
i?php
require_once('chorus/Utils.php');
require_once('chorus/Kestrel.php');
require_once('chorus/DataService.php');
require_once('chorus/Shard.php');
Database::set_defaults(array(
'user' => 'tumblr3',
'password' => 'm3MpH1C0Koh39AQD83TFhsBPlOM1Rx9eW55Z8YWStbgTmcgQWJvFt4',
'database' => 'tumblr3',
BOOL isBackgroundingAvailable = (&UIApplicationDidEnterBackgroundNotification != NULL);
if (isBackgroundingAvailable) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForegroundNotification:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
}
@atnan
atnan / LongMethodIsLong.h
Created January 11, 2011 04:45
Longest method signature ever?
// From NPR for iPad
-[MedialetsAdEvent initWithEventID:key:time:adID:conn:lat:lon:alt:uCount:uDur:uDict:horizontalAccuracy:verticalAccuracy:urlCounts:adExit:countHr:countDay:countMon:stringValues:numericValues:breadcrumbs:visitedAdEventLinks:durationValues:direction:directionAccuracy:adSlotName:adVersion:adChildAdID:adParentAdID:adIsAClone:]
@atnan
atnan / Foo.h
Created December 23, 2010 04:36
#import "NDVKVOMacros.h"
@implementation Foo
@synthesize bar;
- (id)init {
@implementation UIView (CIImageAdditions)
- (CIImage *)CIImage {
UIImage* image = nil;
UIGraphicsBeginImageContext(self.frame.size); {
CGContextRef context = UIGraphicsGetCurrentContext();
[self.layer renderInContext:context];
image = UIGraphicsGetImageFromCurrentImageContext();
# Add this to your global ~/.gitconfig so that your read-only
# Git URLs (e.g. in submodules) are swapped out for your
# read-write URL
#
[url "https://USERNAME@github.com/USERNAME/"]
insteadOf = "git://github.com/USERNAME/"
insteadOf = "http://github.com/USERNAME/"
#
# Takes a PNG that has been optimised by Xcode for display on iOS devices, and
# creates a new, unoptimised file that can be opened in Preview. If you don't
# supply a second argument, the output file will be named in-uncrushed.png
#
# See: http://developer.apple.com/iphone/library/qa/qa2010/qa1681.html
#
function uncrush() {
local infile="$1"; local outfile="$2"