Skip to content

Instantly share code, notes, and snippets.

View kwylez's full-sized avatar

Cory D. Wiles kwylez

View GitHub Profile
/// Iterate and add subviews plus the index value
var currentIndex = 0
let updatedIndexes = items.map({ (item: MenuItem) -> MenuItem in
item.index += currentIndex
item.delegate = self
currentIndex++
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
@kwylez
kwylez / gist:8286357
Created January 6, 2014 17:34
Using Dispatch Groups for asynchronous image processing
#import <ImageIO/ImageIO.h>
#import <AssetsLibrary/AssetsLibrary.h>
static char const *__imageResizeQueueName = "com.macspots.imageresize.queue";
static CGSize const MaxSizeForLargeImage = {640, 640};
static CGSize const MaxSizeForThumbnailImage = {100, 100};
static CGSize const MaxSizeForIPadThumbnailImage = {300, 300};
static dispatch_queue_t __imageResizeDispatchQueue;
@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;
@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: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 / 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: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 / 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: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;