Skip to content

Instantly share code, notes, and snippets.

View danielctull's full-sized avatar

Daniel Tull danielctull

View GitHub Profile
@danielctull
danielctull / dct_weak.h
Created December 29, 2011 02:21 — forked from rowanj/dct_weak.h
ARC macros for weak references
#ifndef _DCT_WEAK_H
#define _DCT_WEAK_H
// Macros for portable support of notionally weak properties with ARC
// Forked from https://gist.github.com/1354106
// Updated by Rowan James
// Available at https://gist.github.com/1530868
// Defines:
// dct_weak to be used as a replacement for the 'weak' keyword:
// @property (dct_weak) NSObject* propertyName;
@danielctull
danielctull / dct_weak.h
Created January 21, 2012 11:13 — forked from rowanj/dct_weak.h
ARC macros for weak references
#ifndef _DCT_WEAK_H
#define _DCT_WEAK_H
// Macros for portable support of notionally weak properties with ARC
// Contributors: Daniel Tull, Abizer Nasir, Rowan James
// Current version: https://gist.github.com/1652385
// Defines:
// dct_weak to be used as a replacement for the 'weak' keyword:
// @property (dct_weak) NSObject* propertyName;
// __dct_weak to be used as a replacement for the '__weak' variable attribute:
@danielctull
danielctull / GlobalSettings.plist
Created August 7, 2012 14:48 — forked from samdeane/GlobalSettings.plist
Script for generating appledoc docs
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>--project-company</key>
<string>Elegant Chaos</string>
<key>--company-id</key>
<string>com.elegantchaos</string>
<key>--keep-undocumented-objects</key>
<false/>
@danielctull
danielctull / ShakeAnimation.m
Created September 7, 2012 16:14 — forked from pieteromvlee/ShakeAnimation.m
ShakeAnimation; a variant on @danielctull's versopm
@implementation ShakeAnimation {
CGRect originalRect;
NSInteger counter;
}
+ (void)shakeView:(UIView *)view {
[[[[self class] alloc] initWithView:view] shake];
}
- (id)initWithView:(UIView *)view {
fetchRequest.entity = [RNPFeedListEntry entityInManagedObjectContext:self.managedObjectContext];
// this is the main predicate to get the feed entries that belong to the us
NSPredicate *ownerPredicate = [NSPredicate predicateWithFormat:@"%K == %@ AND %K.%K == %@",
RNPFeedListEntryRelationships.owner, self, RNPFeedListEntryRelationships.feed,
RNPFeedAttributes.action, @(FeedAction_LIKE), self];
// this is the predicate to check that we have the required item
NSPredicate *itemPopulatedPredicate = [NSPredicate predicateWithFormat:@"(%K.%K == nil) OR (%K.%K != nil)",
RNPFeedListEntryRelationships.feed, RNPFeedAttributes.itemId,
RNPFeedListEntryRelationships.feed, RNPFeedRelationships.item];
fetchRequest.predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[ownerPredicate, itemPopulatedPredicate]];
enum MyEnum {
case StateA
case StateB
}
let enumValueA = MyEnum.StateA
let enumValueB = MyEnum.StateB
if enumValueA == enumValueB {
CGRect PSPDFRectSafeInset(CGRect rect, CGFloat dx, CGFloat dy) {
CGRect insetRect = CGRectInset(rect, dx, dy);
if (CGRectIsNull(insetRect)) {
insetRect = CGRectMake(CGRectGetMidX(rect), CGRectGetMidY(rect), 0.f, 0.f);
}
return insetRect;
}