Skip to content

Instantly share code, notes, and snippets.

View wtsnz's full-sized avatar
🛠️
Working

Will Townsend wtsnz

🛠️
Working
View GitHub Profile
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
#ifdef DEBUG
# define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
# define ULog(...)
#endif
@wtsnz
wtsnz / animated.m
Last active August 29, 2015 13:57
Implementing Animated:(BOOL)animated
- (void)hideAdBannerViewAnimated:(BOOL)animated
{
void (^animations)() = ^void() {
CGRect addBannerViewFrame = self.adBannerView.frame;
addBannerViewFrame.origin.y = self.view.frame.size.height;
self.adBannerView.frame = addBannerViewFrame;
};
if (animated) {
[UIView animateWithDuration:0.3 delay:0.0 usingSpringWithDamping:1.0 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:animations completion:nil];
@wtsnz
wtsnz / gist:57f649e096778b35701f
Created November 17, 2014 11:27
Print out font families
NSArray *fontFamilies = [UIFont familyNames];
for (int i = 0; i < [fontFamilies count]; i++)
{
NSString *fontFamily = [fontFamilies objectAtIndex:i];
NSArray *fontNames = [UIFont fontNamesForFamilyName:[fontFamilies objectAtIndex:i]];
NSLog (@"%@: %@", fontFamily, fontNames);
}
extension UIDevice {
/**
Returns the name of the current devices' owner, maybe.
Usually iPhones are named something like "Will's iPhone", or "Will's iPad", this method is a simple, unreliable way of getting the persons name from that string.
:returns: Optional string that might be the owners name.
*/
func ownersName() -> String? {
return UIDevice.currentDevice().name.componentsSeparatedByString("'").first
@wtsnz
wtsnz / Timer.swift
Created September 14, 2015 06:25
A simple way to time functions in swift
import Foundation
import CoreFoundation
class Timer {
let startTime:CFAbsoluteTime
var endTime:CFAbsoluteTime?
init() {
startTime = CFAbsoluteTimeGetCurrent()
import Foundation
import UIKit
extension UIImage {
class func imageForColor(color: UIColor) -> UIImage {
let rect = CGRectMake(0, 0, 1, 1)
UIGraphicsBeginImageContext(rect.size)
@wtsnz
wtsnz / openssl-build.sh
Last active September 28, 2015 10:21 — forked from felix-schwarz/openssl-build.sh
Updated script that builds OpenSSL for OS X, iOS and tvOS. Bitcode enabled for iOS, tvOS. Updated to build for tvOS, use the latest SDKs, skip installing man pages (to save time), download the OpenSSL source over HTTPS, patch OpenSSL for tvOS to not use fork(). Currently requires Xcode7.1b or later (for the tvOS SDK).
#!/bin/bash
# This script downlaods and builds the iOS and Mac openSSL libraries with Bitcode enabled
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# https://gist.github.com/foozmeat/5154962
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Felix Schwarz, IOSPIRIT GmbH, @felix_schwarz.
@wtsnz
wtsnz / 0014-add-fembed-bitcode-flag.patch
Created September 28, 2015 20:10
Add -fembed-bitcode to MobileVLCKit
From 968ff57dd5830d9962d429e5757737274305e12f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?W=20T=20K=C3=BChne?= <will@townsend.io>
Date: Fri, 29 Sep 2015 18:34:26 +0200
Subject: [PATCH 13/13] add -fembed-bitcode
diff --git a/extras/package/ios/build.sh b/extras/package/ios/build.sh
index f514732..4917973 100755
--- a/extras/package/ios/build.sh
+++ b/extras/package/ios/build.sh
@wtsnz
wtsnz / gist:5712546
Created June 5, 2013 08:46
Install Node.JS on Amazon Linux
# Update the system
sudo yum update
# Install gcc, make, openssl, git
sudo yum install gcc-c++ make
sudo yum install openssl-devel
sudo yum install git
# Clone the git repo and build
git clone git://github.com/joyent/node.git
@wtsnz
wtsnz / gist:5726768
Created June 7, 2013 02:51
Automatic iOS Deployments Bash Script
#!/bin/bash
cd /Shared\ Items/Public/AUTO/project
BUILDDIR="/Shared Items/Public/AUTO/project_build"
NAME="Project"
CONFIGURATION="Ad Hoc"
API_TOKEN="..."
TEAM_TOKEN="..."