Skip to content

Instantly share code, notes, and snippets.

Avatar

Cory D. Wiles kwylez

View GitHub Profile
View cloudkit-swift-3-error.swift
import Foundation
import CloudKit
public enum CloudKitError: Error {
case general(String)
}
public enum CloudKitResult<T, ResultError: Error> {
case success(T)
case failure(ResultError)
View RZLImageVIew.swift
//
// UserProfileImageView.swift
// Rezli
//
// Created by Cory D. Wiles on 7/27/16.
// Copyright © 2016 Rezli. All rights reserved.
//
import Foundation
View firebase_copy_config.sh
#!/bin/sh
PATH_TO_CONFIGURATIONS="$SRCROOT/../Configurations"
FIRServiceAccountDevelopment="$PATH_TO_CONFIGURATIONS/FIRServiceAccounts-Dev.json"
FIRServiceAccountRelease="$PATH_TO_CONFIGURATIONS/FIRServiceAccounts-Prod.json"
FIRConfigDevelopment="$PATH_TO_CONFIGURATIONS/GoogleService-Info-Dev.plist"
FIRConfigRelease="$PATH_TO_CONFIGURATIONS/GoogleService-Info-Prod.plist"
View firebase_listen.swift
private func listenOnChannel(channel: Firebase, handler: RealTimeDataHandler) -> Void {
var initialDataLoaded: Bool = false
let firebaseHandleRef: FirebaseHandle = channel.observeEventType(.Value, withBlock: {[unowned self] snapshot in
Log.print("listening to the channel from manager and got a response \(snapshot.key) -> \(snapshot.value) and [\(channel.description())]")
if !initialDataLoaded { return }
View DictionaryIteration+Filter.m
- (void)executeLocalNotificationWithLaunchHookKey:(NSString *)launchHookKey
hookType:(RTVNotificationHookType)hookType
userInfo:(NSDictionary *)userInfo {
NSDictionary *dict = [self.notificationConfiguration notificationHooks];
NSSet *notificationIgnoreTypes = [self.notificationConfiguration notificationTypesToIgnore];
[dict enumerateKeysAndObjectsUsingBlock:^(NSString *key, id hook, BOOL *stop) {
if ([key isEqualToString:launchHookKey] && ![notificationIgnoreTypes containsObject:key]) {
View DictionaryIteration+Filter.swift
private func execute(launchKey: String, hookType: NotificationHookType, info: Dictionary<String, AnyObject>) -> Void {
guard let notificationConfiguration = self.configuration,
let notificationHooks = notificationConfiguration.notificationHooks,
let ignoreTypes = notificationConfiguration.notificationTypesToIgnore else { return }
let hook = notificationHooks.filter({ k, v in k == launchKey && !ignoreTypes.contains(k)})
if !hook.isEmpty {
View uiimageview_map.swift
/// 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++
@kwylez
kwylez / SchemeRedirect.m
Created Aug 12, 2015
After the "OAuth dance" is complete the request is never sent back to the app. I didn't have this happen with UIWebViews.
View SchemeRedirect.m
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
RTVLog(@"decidePolicyForNavigationAction %@", navigationAction);
if (navigationAction.navigationType == WKNavigationTypeOther) {
NSURL *url = navigationAction.request.URL;
UIApplication *app = [UIApplication sharedApplication];
if ([[url scheme] isEqualToString:RabbleURLScheme]) {
@kwylez
kwylez / gist:d0dce12127c6d91ba448
Created Apr 29, 2015
AppDelegate without Storyboard Template
View gist:d0dce12127c6d91ba448
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
lazy var navigationController: UINavigationController = {
let navController = UINavigationController(rootViewController: self.rootViewController)
View UIViewExtensions
//
// UIViewExtensions.swift
// Singles
//
// Created by Cory D. Wiles on 2/19/15.
// Copyright (c) 2015 Cory WIles. All rights reserved.
//
import UIKit