Skip to content

Instantly share code, notes, and snippets.

View wtsnz's full-sized avatar
🛠️
Working

Will Townsend wtsnz

🛠️
Working
View GitHub Profile
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 / buildMobileVLC.sh
Created September 27, 2015 12:57 — forked from fbradyirl/buildMobileVLC.sh
Modified to build tvOS framework. run with ./buildMobileVLCKit.sh -t -f
#!/bin/sh
# Copyright (C) Pierre d'Herbemont, 2010
# Copyright (C) Felix Paul Kühne, 2012-2015
set -e
BUILD_DEVICE=yes
BUILD_SIMULATOR=yes
BUILD_STATIC_FRAMEWORK=no
SDK=`xcrun --sdk iphoneos --show-sdk-version`
@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 / _service.md
Last active March 19, 2016 04:31 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
# Delete any existing NSAppTransportSecurity configurations
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
# Add the NSAppTransportSecurity dictionary again
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
# Add s3.amazonaws.com NSExceptionRequiresForwardSecrecy and set it to false
# This is a requirement of the Carnival.io SDK
/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSExceptionDomains:s3.amazonaws.com dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
@wtsnz
wtsnz / delazy.js
Last active August 2, 2016 22:17
Super hacky script to delazy your swift files to decrease compile time.
//
// Hacky script to convert lazy loaded closures into private instance functions
// The script ignores Pods, Carthage and build folders, and only looks for
// .swift files
// This doesn't work on all cases, and may break things. Be warned ⚠️
//
// Usage:
// node delazy.js <folder path>
//
@wtsnz
wtsnz / index.js
Created February 18, 2017 00:57
Fabric to Pushover: New Users
var Pushover = require('node-pushover');
var moment = require('moment');
var request = require('request');
// Fill out with your secrets
var secrets = {
pushover: {
token: '',
user: ''
},