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:d0dce12127c6d91ba448
Created April 29, 2015 14:09
AppDelegate without Storyboard Template
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
lazy var navigationController: UINavigationController = {
let navController = UINavigationController(rootViewController: self.rootViewController)
//
// UIViewExtensions.swift
// Singles
//
// Created by Cory D. Wiles on 2/19/15.
// Copyright (c) 2015 Cory WIles. All rights reserved.
//
import UIKit
@kwylez
kwylez / MSImageCache.swift
Created September 4, 2014 15:25
First attempt of using Swift. This is a port of an image cache utility that I wrote for one of my apps
//
// MSImageCache.swift
// Stasis
//
// Created by Cory D. Wiles on 8/17/14.
// Copyright (c) 2014 Macspots. All rights reserved.
//
import Foundation
import UIKit
@kwylez
kwylez / gist:05b735162ac588b980f7
Created July 29, 2014 02:01
Blur animation for Stasis' Cover Image View. This works for iOS8 only
//
// STSCoverImageViewController.m
// Stasis
//
// Created by Cory D. Wiles on 6/5/14.
// Copyright (c) 2014 Macspots. All rights reserved.
//
#import "STSCoverImageViewController.h"
#import "Profile.h"
@import MobileCoreServices;
static CFStringRef UTTypeForImageData(NSData *data) {
const unsigned char * bytes = [data bytes];
if (data.length >= 8) {
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) {
return kUTTypePNG;
}
}
//
// 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};