Skip to content

Instantly share code, notes, and snippets.

View kwylez's full-sized avatar

Cory D. Wiles kwylez

View GitHub Profile
@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 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"
@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
//
// 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 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)
@kwylez
kwylez / SchemeRedirect.m
Created August 12, 2015 17:17
After the "OAuth dance" is complete the request is never sent back to the app. I didn't have this happen with UIWebViews.
- (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]) {
- (void)sayHello {
NSLog(@"hello");
}
- (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) {
<?php
//Example Code
private function _notifyGroup() {
$data = array();
$data = $this->getForm()->getValues();
/**
* Setup view instance to pass to notifier
*/
<?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) {