Skip to content

Instantly share code, notes, and snippets.

View tanner0101's full-sized avatar
💭
💧

Tanner tanner0101

💭
💧
View GitHub Profile
@tanner0101
tanner0101 / CoreBluetoothExtensions.swift
Last active August 29, 2015 14:25
Easily identify which state a CBCentralManager or CBPeripheralManager is in
/**
CoreBluetoothExtensions.swift
Easily identify which state a CBCentralManager or CBPeripheralManager is in
<https://gist.github.com/tannernelson/f6ba585244afa80b06d2>
*/
import CoreBluetooth
@tanner0101
tanner0101 / UIViewExtensions.swift
Last active August 29, 2015 14:27
Instantiate a UIView object from a nib in the NSBundle.
/**
UIViewExtensions.swift
Instantiate a UIView object from a nib in the NSBundle.
<https://gist.github.com/tannernelson/4e8e8a31553e46de81fe>
*/
import UIKit
@tanner0101
tanner0101 / DoubleExtensions.swift
Last active October 30, 2015 23:20
Converts 16-bit 8:8 Fixed Point numbers to swift Doubles.
/**
Converts 16-bit 8:8 Fixed Point numbers to swift Doubles.
Fixed Point mathematical functions:
<https://courses.cit.cornell.edu/ee476/Math/>
Compare the results from these calls to the Examples from the "Fixed Point mathematical functions" paper.
Double.from88FixedPoint(0, 0)
Double.from88FixedPoint(1, 0)
@tanner0101
tanner0101 / NSTimeIntervalExtensions.swift
Last active November 21, 2015 16:18
Return human readable string for any NSTimeInterval
/**
NSTimeIntervalExtensions.swift
Return human readable string for any NSTimeInterval
<https://gist.github.com/tannernelson/e5d2e0bab5a58b938b08>
*/
import Foundation
@tanner0101
tanner0101 / UITableViewExtensions.swift
Last active December 15, 2015 19:48
Easily animate a UITableView between two data sources.
/*
UITableViewExtensions.swift
Easily animate a UITableView between two data sources.
Ensure that the objects in your data source implement the Equatable protocol.
This means they must have a declaration `MyClass: Equatable` followed by
`public func ==(lhs: MyClass, rhs: MyClass) -> Bool {
public typealias Byte = UInt8
public struct Data {
public var bytes: [Byte]
public init(_ bytes: [Byte]) {
self.bytes = bytes
}
}
@tanner0101
tanner0101 / vapor-protocols.swift
Last active May 7, 2016 22:47
Vapor Protocols
import Foundation
import Vapor
/**
* This protocol defines router objects that can be used to relay
* different paths to the application
*/
public protocol RouterDriver {
func route(request: Request) -> Request.Handler?
@tanner0101
tanner0101 / main.swift
Last active June 13, 2016 02:36
Vapor Benchmark
import Vapor
import Fluent
import FluentSQLite
let app = Application()
do {
let driver = try SQLiteDriver(path: "/home/helper/database/test.sqlite")
Database.default = Database(driver: driver)
} catch {
class BenchmarkController < ActionController::Base
def plaintext
render plain: "Hello world"
end
def json
a = [1, 2, 3]
d = {"one" => 1, "two" => 2, "three" => 3}
r = {"array" => a, "dict" => d, "int" => 42, "string" => "test", "double" => 3.14, "null" => nil}
@tanner0101
tanner0101 / database.yml
Created June 13, 2016 02:40
Rails Benchmark
production:
<<: *default
database: /home/helper/database/test.sqlite