Skip to content

Instantly share code, notes, and snippets.

Avatar

Cory D. Wiles kwylez

View GitHub Profile
View UTTypeForImageData.m
@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;
}
}
@kwylez
kwylez / gist:05b735162ac588b980f7
Created Jul 29, 2014
Blur animation for Stasis' Cover Image View. This works for iOS8 only
View gist:05b735162ac588b980f7
//
// 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"
@kwylez
kwylez / MSImageCache.swift
Created Sep 4, 2014
First attempt of using Swift. This is a port of an image cache utility that I wrote for one of my apps
View MSImageCache.swift
//
// MSImageCache.swift
// Stasis
//
// Created by Cory D. Wiles on 8/17/14.
// Copyright (c) 2014 Macspots. All rights reserved.
//
import Foundation
import UIKit
View UIViewExtensions
//
// UIViewExtensions.swift
// Singles
//
// Created by Cory D. Wiles on 2/19/15.
// Copyright (c) 2015 Cory WIles. All rights reserved.
//
import UIKit
@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)
@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]) {
View gist:594264
- (void)sayHello {
NSLog(@"hello");
}
View gist:595379
- (void)webViewDidFinishLoad:(UIWebView *)webView {
/**
* Since there are a lot redirects then UIWebview delegate methods are called ALOT.
* Therefore I just want to check and make sure that I am only getting the value when the url has my hostname in it
*/
NSRange rangeRound = [[[webView.request URL] absoluteString] rangeOfString:@"corywiles"];
if (rangeRound.length) {
View gist:595456
<?php
require_once 'Zend/Service/Twitter.php';
class CW_Twitter extends Zend_Service_Twitter {
public function __construct($username, $password) {
parent::__construct($username, $password);
}
public function getOtherUserFriends($name) {
View gist:595396
<?php
//Example Code
private function _notifyGroup() {
$data = array();
$data = $this->getForm()->getValues();
/**
* Setup view instance to pass to notifier
*/