Skip to content

Instantly share code, notes, and snippets.

View kwylez's full-sized avatar

Cory D. Wiles kwylez

View GitHub Profile
@kwylez
kwylez / gist:3909449
Created October 18, 2012 01:56
Load Images From OCUnit Test Target Only
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:imageName ofType:@"png"];
[[UIImage alloc] initWithContentsOfFile:path]
@kwylez
kwylez / ModelManager-Broken.m
Created October 29, 2012 15:05
BROKEN example of concurrent code. This is for comparison ONLY
//
// ModelManager.m
// ThreadingHell
//
// Created by Cory D. Wiles on 10/19/12.
// Copyright (c) 2012 Cory D. Wiles. All rights reserved.
//
#import "ModelManager.h"
#import "NSMutableString+CoryAdditions.h"
@kwylez
kwylez / gist:4125642
Created November 21, 2012 15:59
WNPhoto Example Meta Data
timelineOfPhotos: (
{
clazz = WNPhoto;
createdAt = 1352085590920;
createdBy = U60G4tqQYg4Vly0gJdfpE7;
ffRL = "/UserPhotos";
ffRefs = (
{
name = event;
type = FFO;
@kwylez
kwylez / checkUASConfig.sh
Last active December 14, 2015 01:39
Modified AirConfig.plist from Urbanship that will copy over plist file based upon the XCode configuration.
#!/bin/sh
# Copyright 2009-2012 Urban Airship Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
@kwylez
kwylez / gist:5301597
Created April 3, 2013 14:16
Custom UIViewTransition Example
- (void)transitionFromViewController:(UIViewController *)fromViewController
toViewController:(UIViewController *)toViewController
withAnimationType:(EPBUIViewAnimationTransition)animation
fromFrame:(CGRect)aFrame
withOverLayImage:(NSString *)overlayName {
static NSInteger standardImageTag = 9999;
if (fromViewController == toViewController) {
return;
@kwylez
kwylez / gist:5337918
Last active March 2, 2020 06:09
Example implementation of listening for iTunes/Spotify track changes and displaying information in the NotificationCenter. Article reference: http://blog.corywiles.com/now-playing-with-spotify-and-itunes
//
// AppDelegate.m
//
//
// Created by Cory D. Wiles on 10/8/12.
// Copyright (c) 2013 Cory D. Wiles. All rights reserved.
//
#import "AppDelegate.h"
#import "iTunes.h"
@kwylez
kwylez / async-test.m
Last active December 18, 2015 05:19
quick example of using block property to handle async unit tests for iOS. This assumes you're using SenTest
@property (nonatomic, copy) void (^testForCompletionBlock)(BOOL *testCompleted);
- (void)setUp {
[super setUp];
_testForCompletionBlock = ^(BOOL *testCompleted) {
while (!*testCompleted) {
@kwylez
kwylez / gist:6451427
Created September 5, 2013 15:05
Thread safe Antenna approach
- (void)addChannel:(id <AntennaChannel>)channel forName:(NSString *)name {
dispatch_barrier_async(_channelsThreadQueue, ^{
/**
* Has this channel already been added?
*/
if ([self channelExists:name]) {
return;
}
NSDictionary *notifInfo = @{AntennaChannelNotificationDictKey : name};
@kwylez
kwylez / gist:6464147
Created September 6, 2013 13:55
FatFractal Extension Example: Delete All Records for Given Resource
var ff = require('ffef/FatFractal');
exports.deleteAllForResource = function() {
var data = ff.getExtensionRequestData();
var finalResponse = {};
var r = ff.response();
var resourceName = data.httpParameters.resourceName;
var responseCode = "200";
var deletedURLs = [];
@kwylez
kwylez / gist:6464175
Created September 6, 2013 13:56
FatFractal Extension Example: Get Total Number of Records for Given Resource
var ff = require('ffef/FatFractal');
exports.countForResource = function() {
var r = ff.response();
var data = ff.getExtensionRequestData();
var resourceName = data.httpParameters.resourceName;
var resourceCollection = [];
var responseCode = "200";
var total = 0;