Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
lukeredpath / AssertEventually.h
Created August 3, 2010 13:20
Enables simple and elegant testing of asynchronous/threaded code with OCUnit, blocks and OCHamcrest
//
// AssertEventually.h
// LRResty
//
// Created by Luke Redpath on 03/08/2010.
// Copyright 2010 LJR Software Limited. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HCMatcher.h"
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@akisute
akisute / AsyncSenTestingKitTests.h
Created March 17, 2012 02:23
SenAsyncTestCase - Asynchronous capable SenTestCase
//
// AsyncSenTestingKitTests.h
// AsyncSenTestingKitTests
//
// Created by 小野 将司 on 12/03/17.
// Copyright (c) 2012年 AppBankGames Inc. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
#import "SenAsyncTestCase.h"
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active June 5, 2024 22:16 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@ryancole
ryancole / foo.m
Created August 7, 2012 01:06
Convert NSPredicate into NSDictionary for use as a query string in an AFNetworking HTTP request
- (NSURLRequest *)requestForFetchRequest:(NSFetchRequest *)fetchRequest
withContext:(NSManagedObjectContext *)context {
// init the query string dictionary
NSMutableDictionary *queryString = nil;
// if we're given a predicate, convert it to a dictionary
if (fetchRequest.predicate) {
if ([fetchRequest.predicate isKindOfClass:[NSCompoundPredicate class]]) {
@iwasrobbed
iwasrobbed / gist:5528897
Last active June 5, 2020 20:34
UICollectionView w/ NSFetchedResultsController & NSBlockOperation. Idea originated from Blake Watters (https://github.com/AshFurrow/UICollectionView-NSFetchedResultsController/issues/13)
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
self.blockOperation = [[NSBlockOperation alloc] init];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
__weak UICollectionView *collectionView = self.collectionView;
@brentsimmons
brentsimmons / gist:5810992
Last active January 3, 2021 02:22
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
@kaelzhang
kaelzhang / systemstats.sh
Created August 9, 2014 04:21
Resolving systemstats CPU Usage Issues
sudo launchctl stop com.apple.systemstatsd
sudo launchctl stop com.apple.systemstats.periodic
sudo launchctl stop com.apple.systemstats.analysis
mkdir /Users/Shared/oldsysstats
sudo mv /private/var/db/systemstats/* /Users/Shared/oldsysstats
@mbbischoff
mbbischoff / LCKIndexedFetchedResultsController.h
Last active August 29, 2015 14:10
LCKIndexedFetchedResultsController is a NSFetchedResultsController subclass that attempts to solve the problem of sorting a fetched collection into correctly alphabetized sections for every locale. It does things like making sure that the `#` character shows up at the bottom instead of the top of the section index titles.
//
// LCKIndexedFetchedResultsController.h
// Quotebook
//
// Created by Andrew Harrison on 7/26/14.
// Copyright (c) 2014 Lickability. All rights reserved.
//
@import CoreData;