Skip to content

Instantly share code, notes, and snippets.

View asmallteapot's full-sized avatar
😴
😴

Ellen Teapot asmallteapot

😴
😴
View GitHub Profile
@justin
justin / NSTimer+Blocks
Created September 9, 2011 15:40
NSTimer+Blocks
typedef void (^SGBlock)();
@interface NSTimer (Blocks)
+ (id)scheduledTimerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)shouldRepeat block:(SGBlock)block;
+ (id)timerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)shouldRepeat block:(SGBlock)block;
@end
@ttscoff
ttscoff / DefaultKeyBinding.dict
Created November 8, 2011 23:45
Flexible DefaultKeyBinding trick to continue plain text lists
// Add to (or create) ~/Library/KeyBindings/DefaultKeyBinding.dict
// Incorporated change by Lri to not require additional words on the line to work
// fixed to handle first character of list item being non-alphanumeric
// Issues:
// If there are more than one symbols ([[, ![, etc.) at the beginning of the line, anything beyond the first one is captured and added to new line
// FIXED: Entering more than one blank item in a row and then using ⌘Z leaves a placeholder character on the previous line.
{
@btedev
btedev / jongify.rb
Created December 30, 2011 04:01
Make a custom Kim Jong Il funeral procession image
# Create your very own Kim Jong Il funeral magic!
# Requires ImageMagick.
# OS X: brew install imagemagick
# Ubuntu: sudo apt-get install imagemagick
#
# Background image from Dustin Fenstermacher via http://gawker.com/5871682/give-yourself-a-dictators-funeral-with-this-kim-jong+il-photoshop-template
abort 'usage: jongify.rb image_file' unless ARGV.size == 1
original_image = ARGV[0]
@plantpurecode
plantpurecode / NSIndexPath+JRAdditions.m
Created January 3, 2012 22:56
A handy category on NSIndexPath.
@implementation NSIndexPath (JRAdditions)
- (NSIndexPath *) indexPathByAddingRows:(NSInteger)rows andSections:(NSInteger)sections {
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:MIN(NSIntegerMax, [self row] + rows)
inSection:MIN(NSIntegerMax, [self section] + sections)];
return newIndexPath;
}
- (NSIndexPath *) indexPathByAddingRows:(NSInteger) rows {
return [self indexPathByAddingRows:rows andSections:0];
@panicsteve
panicsteve / gist:1641705
Created January 19, 2012 18:26
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
@asmallteapot
asmallteapot / gist:1664575
Created January 23, 2012 18:07
Using C99 for clever and non-fragile UITableView configuration. Allows implicit defaults. Copypasta’d from a screencap tweeted by @jonsterling: http://twitpic.com/80uyfp
typedef enum {
kAccomplishmentTitleSection = 0,
kAccomplishmentCategorySection,
kNumberOfSections
} NESTemplateEditTableSections;
static NSString * const kCellIdentifiers[] = {
[kAccomplishmentTitleSection] = @"AccomplishmentTitleCell",
[kAccomplishmentCategorySection] = @"AccomplishmentCategoryCell"
};
@ttscoff
ttscoff / massnippet.txt
Created March 18, 2012 20:52
Auto-redeem link for Mac App Store promo codes
macappstores://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/redeemLandingPage?code=XXXXXXXXX
@iamleeg
iamleeg / pileOfPoo.m
Created March 22, 2012 01:51
The pile of poo Objective-C method
#import <Foundation/Foundation.h>
@interface A: NSObject
@end
@implementation A
void pileOfPoo(id self, SEL _cmd) {
NSLog(@"💩");
}
@alloy
alloy / KWChangeMatcher.h
Created April 12, 2012 14:36
An ‘assert difference’ type of matcher for Kiwi.
#import <Kiwi/KWMatcher.h>
typedef NSInteger (^KWChangeMatcherCountBlock_t)();
@interface KWChangeMatcher : KWMatcher {
@private
BOOL anyChange;
NSInteger expectedDifference, expectedTotal, actualTotal;
KWChangeMatcherCountBlock_t countBlock;
}
@henrik
henrik / prawndown.coffee
Created May 23, 2012 13:48
Prawndown! Super-tiny subset of Markdown for use with the Prawn PDF lib.
class Prawndown
constructor: (@text) ->
toPrawn: ->
@text.
replace(/\n/g, "<br>\n").
replace(/^# (.+)/gm, "<b>$1</b>")
# Use:
console.log (new Prawndown("# Foo\nbar")).toPrawn()