Skip to content

Instantly share code, notes, and snippets.

View badeen's full-sized avatar

Jonathan Badeen badeen

View GitHub Profile
@badeen
badeen / A Call for Tinder
Last active December 21, 2015 10:29
We are looking to fill some positions at Tinder.
A Call for Tinder
We at Tinder are looking to hire
Some fresh cool coals to fuel our fire.
That lump given proper compression,
a clear diamond revealed might make an impression.
A bit about us
As evidenced thus
The way that we roll
@badeen
badeen / gist:5278042
Created March 30, 2013 19:31
I'm guessing this is bad when multiple contexts are at play.
- (void)managedObjectContextDidChange:(NSNotification *)note
{
NSArray *updatedObjects = [note userInfo][NSUpdatedObjectsKey];
if ([updatedObjects containsObject:self.user]) {
[self updateView:YES];
}
}
@badeen
badeen / gist:5226053
Created March 23, 2013 01:51
This crashes as a result of line 3. Is this not how you perform searches using MagicalRecord.
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"match == nil && failedChoice == NO"];
NSArray *users = [TNDRUser MR_findAllWithPredicate:predicate inContext:localContext];
for (TNDRUser *user in users) {
[user MR_deleteEntity];
}
} completion:nil];
@badeen
badeen / gist:5051302
Created February 27, 2013 20:16
Is this a valid fetched property predicate? If not, what am I doing wrong and/or can I actually do this with a fetched property? I'm guessing it's not because I believe I'm crashing when attempting to use it. The goal is to ask a Match instance for all of its messages which have not been viewed.
"match.matchID == $FETCH_SOURCE.matchID && viewed == NO".
-------------------MODEL DETAILS ---------------------
Match (entity)
messages (to-many relationship with Message entity)
viewed (boolean attribute)
matchID (string attribute)
unviewedMessages (fetched property with - see above)
PREDICATE = "match.matchID == $FETCH_SOURCE.matchID && viewed == NO"
[[FBSession activeSession] closeAndClearTokenInformation];
if (NSClassFromString(@"ACAccountStore")) {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
if ([accountStore respondsToSelector:NSSelectorFromString(@"ACAccountStoreRemoveCompletionHandler")]) {
ACAccountType *fbType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray *accounts = [accountStore accountsWithAccountType:fbType];
ACAccount *account = [accounts lastObject];
if (account) {
[accountStore renewCredentialsForAccount:account completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {
- (void)drawLinesInRect:(CGRect)rect forFont:(UIFont *)font
{
CGFloat maxLineHeight = 30.0f;
CGFloat fontLineHeight = roundf(font.lineHeight);
CGFloat fontBaselineAdjustment = roundf(-font.descender);
CGFloat startY = fmodf(yOffset, fontLineHeight);
CGFloat totalDrawnLines = (int)(floorf(CGRectGetHeight(rect) / fontLineHeight));
for (NSUInteger drawnLine = 0; drawnLine < totalDrawnLines; drawnLine++) {
Suppose I make an app like Instagram. As soon as a photo is taken I upload the original to the server. What's good about this is that it gets it that much closer to being ready to be viewed by others. You can simultaneously allow the user to do other stuff while that's being done. The user now applies and modifies the photo using Core Image filters. When the user finishes instead of uploading a new copy of the modified photo you simply send the information necessary to recreate the effect on the server. Almost instantly that image will be available on the server for others to see. The user won't have to wait for something to upload. You also now have the benefit of having the original photo which maybe you show side by side or allow the user to modify at a later point.
This is just one instance off the top of my head. I'm sure there are many more useful things that could be done when interfacing with iOS apps specifically.
- (NSInteger)numberOfSectionsInCollectionView:(PSTCollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(PSTCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [_photos count];
}
- (IBAction)open:(id)sender
{
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 1.0f / -2000.0f;
CATransform3D endScaleTransform = CATransform3DMakeScale(0.8f, 0.8f, 1.0f);
CATransform3D startTransform = perspectiveTransform;
CATransform3D endTransform = CATransform3DConcat(endScaleTransform, perspectiveTransform);
CATransform3D middleTransform = CATransform3DConcat(CATransform3DMakeRotation(M_PI_4 / 2.0f, 1, 0, 0), endTransform);
@badeen
badeen / gist:3876259
Created October 11, 2012 23:20
MixPanel iOS problems
Actual API Problems
- It raises an exception when you pass in an empty string for sharedInstanceWithToken. This is just a horrible practice. I had previously been using an empty string so that I wouldn't track data from our test server/app. NEVER EVER RAISE AN EXCEPTION. Just NSLog it and return nil if you must.
- It raises an exception when calling sharedInstance before sharedInstanceWithToken. NEVER EVER RAISE AN EXCEPTION. Just NSLog it and return nil if you must.
- I see no good reason to have a separate object and methods for MixpanelPeople. This seems like some sort of weird name spacing attempt or something like that. This is not done in Objective-C. It is wrong.
- set:to: and set: are horrible, horrible method names. Just read the Objective-C coding guidelines by Apple. This is just plain wrong.
- The defines like DebugLog need to use an #ifndef. DebugLog is a commonly used thing by developers and you are attempting to redefine it. Be a good citizen and don't do that.
Doc Problems