Skip to content

Instantly share code, notes, and snippets.

View tanner0101's full-sized avatar
💭
💧

Tanner tanner0101

💭
💧
View GitHub Profile
@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 {
@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 July 25, 2018 11:01
Constrain a subview to all the edges of its superview with one line.
/**
UIViewExtensions.swift
Constrain a subview to all the edges of its superview with one line.
<https://gist.github.com/3dcab950560aea7ebc8f.git>
*/
import UIKit
@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 / LaravelExceptionHandler.php
Last active October 29, 2016 11:08
Use this exception handle for your Laravel 5 based JSON APIs. It serves properly formatted JSON responses instead of the default Laravel HTML error pages.
<?php
/**
* LaravelExceptionHandler.php
*
* Use this exception handle for your Laravel 5 based JSON APIs.
* It serves properly formatted JSON responses instead of the default Laravel HTML error pages.
*
* <https://gist.github.com/tannernelson/cb2d981a3cfeabd425b8>
*/
@tanner0101
tanner0101 / MKMapViewExtensions.swift
Last active January 5, 2024 11:48
Zoom into and center the MKAnnotations on an MKMapView with one line. With our without animation.
/**
MKMapViewExtensions.swift
Zoom into and center the MKAnnotations on an MKMapView with one line. With our without animation.
<https://gist.github.com/tannernelson/45741c070508f081657a>
*/
import MapKit
@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 / IntExtensions.swift
Last active December 22, 2016 05:13
Convert an arbitrary length byte array into a Swift Int
/**
IntExtensions.swift
Convert an arbitrary length byte array into a Swift Int
<https://gist.github.com/tannernelson/e720877bf7700138eb99>
*/
extension Int {
static func fromByteArray(bytes: [UInt8]) -> Int {
@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 / NSDataExtensions.swift
Last active February 3, 2017 04:18
Convert to and from NSData for common Swift types. Includes Eddystone URL conversion.
//
// NSData.swift
// Pods
//
// Created by Tanner Nelson on 9/15/15.
//
//
import Foundation