View gist:1186394
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// method to calculate a standard md5 checksum of this string, check against: http://www.adamek.biz/md5-generator.php | |
- (NSString * )md5 | |
{ | |
const char *cStr = [self UTF8String]; | |
unsigned char result [CC_MD5_DIGEST_LENGTH]; | |
CC_MD5( cStr, strlen(cStr), result ); | |
return [NSString | |
stringWithFormat: @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", | |
result[0], result[1], |
View gist:1216647
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)animationDidStop:(CABasicAnimation *)anim finished:(BOOL)flag | |
{ | |
self.layer.shadowPath = (CGPathRef)anim.toValue; | |
} | |
- (void)updateShadowWithDuration:(NSTimeInterval)duration | |
{ | |
CALayer *layer = self.layer; | |
if (_dropShadow) |
View gist:1393523
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSURL+DTAppLinks.h | |
// DTFoundation | |
// | |
// Created by Oliver Drobnik on 11/25/11. | |
// Copyright (c) 2011 Cocoanetics. All rights reserved. | |
// | |
View gist:1423199
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir gh-pages | |
cd gh-pages | |
git init | |
git remote add origin git@github.com:Cocoanetics/DTWebArchive.git | |
git symbolic-ref HEAD refs/heads/gh-pages | |
# add and commit files | |
git push origin gh-pages |
View gist:1789418
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DTAsyncFileDeleter.m | |
// DTFoundation | |
// | |
// Created by Oliver Drobnik on 2/10/12. | |
// Copyright (c) 2012 Cocoanetics. All rights reserved. | |
// | |
#import "DTAsyncFileDeleter.h" |
View gist:1810427
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long l = 1078768689; | |
// dosdate spec: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724247(v=vs.85).aspx | |
int year = ((l>>25)&127) + 1980; // 7 bits | |
int month = (l>>21)&15; // 4 bits | |
int day = (l>>16)&31; // 5 bits | |
int hour = (l>>11)&31; // 5 bits | |
int minute = (l>>5)&63; // 6 bits | |
int second = (l&31) * 2; // 5 bits |
View gist:1845108
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UIImageJPEGRepresentation | |
NSData *data = UIImageJPEGRepresentation(tileImage, 0.71); | |
[data writeToURL:cacheURL atomically:YES]; | |
// ImageIO | |
#import <ImageIO/ImageIO.h> | |
#import <MobileCoreServices/UTCoreTypes.h> |
View gist:2499146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)addShadowWithColor:(UIColor *)color alpha:(CGFloat)alpha radius:(CGFloat)radius offset:(CGSize)offset | |
{ | |
self.layer.shadowOpacity = alpha; | |
self.layer.shadowRadius = radius; | |
self.layer.shadowOffset = offset; | |
if (color) | |
{ | |
self.layer.shadowColor = [color CGColor]; | |
} |
View gist:2593533
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)keyboardWillShow:(NSNotification *)notification | |
{ | |
NSArray *appWindows = [[UIApplication sharedApplication] windows]; | |
UIWindow *keyboardWindow = [appWindows lastObject]; | |
UIView *keyboardView = [keyboardWindow.subviews objectAtIndex:0]; | |
keyboardView = [keyboardView.subviews objectAtIndex:0]; | |
keyboardView = [keyboardView.subviews objectAtIndex:0]; | |
keyboardView = [keyboardView.subviews objectAtIndex:0]; | |
View gist:2669542
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int test(int a, int b, int c, int d, int e) | |
{ | |
if ((a*b) != 24) return 0; | |
if (d != (b/2)) return 0; | |
if ((a+c)!=(d+e)) return 0; | |
if ((a+b+c+d+e) != 26) return 0; | |
// count occurences of digits | |
int counts[10] = {0,0,0,0,0,0,0,0,0,0}; | |
OlderNewer