Skip to content

Instantly share code, notes, and snippets.

View Jesse-calkin's full-sized avatar

Jesse Jesse-calkin

  • Comcast VIPER
  • Denver, CO
View GitHub Profile
@Jesse-calkin
Jesse-calkin / AVPlayerPlayground.swift
Created March 28, 2018 17:22
An AVFoundation Playground for displaying video via AVPlayer
//: An `AVFoundation` Playground for playing video with `AVPlayer`. Using just a bare `AVPlayer`, there will be no playback controls.
import UIKit
import PlaygroundSupport
import AVFoundation
class MyViewController : UIViewController {
// Other example streams can be found here: https://developer.apple.com/streaming/examples/
let url = URL(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8")!
import UIKit
@IBDesignable public class GradientView: UIView {
// MARK: - Internal
@IBInspectable public var color1: UIColor = UIColor.magentaColor()
@IBInspectable public var color2: UIColor = UIColor.cyanColor()
@IBInspectable public var color3: UIColor = UIColor.clearColor()
@IBInspectable public var color4: UIColor = UIColor.clearColor()
import UIKit
public extension UIColor {
public static func checkerboardColor(size: CGSize? = CGSize(width: 100, height: 100), color1: UIColor? = UIColor.grayColor(), color2: UIColor? = UIColor.darkGrayColor()) -> UIColor? {
guard let checkers = CIFilter(name: "CICheckerboardGenerator") else { return nil }
let color0 = CoreImage.CIColor(color: color1!)
let color1 = CoreImage.CIColor(color: color2!)
@Jesse-calkin
Jesse-calkin / AdjustedExposureImage.swift
Created June 5, 2016 19:48
UIImage extension for creating a new image with adjusted exposure
extension UIImage {
/**
Returns a new `UIImage` with an adjusted exposure value.
- Parameter ev: The amount to adjust the exposure value. Negative for darker, positive for lighter.
- Returns: a new `UIImage` with an adjusted exposure value.
*/
func imageWithAdjustedExposure(ev: Double) -> UIImage? {
guard let cgImage = self.CGImage else { return nil }
@Jesse-calkin
Jesse-calkin / StringTruncationExtension.swift
Last active June 3, 2016 03:09
Adding truncation to Swift Strings
import Foundation
extension String {
func truncateEnd(length: Int, omissionMarker: String? = "...") -> String {
guard self.characters.count > length else { return self }
return self.substringToIndex(self.startIndex.advancedBy(length)) + (omissionMarker ?? "")
}
@Jesse-calkin
Jesse-calkin / UIMotionEffectExtensions.swift
Created March 31, 2016 04:01
UIMotionEffect Extensions
//
// UIMotionEffectExtensions.swift
// Collection Views
//
// Created by jesse calkin on 3/30/16.
// Copyright © 2016 Shoshin Boogie. All rights reserved.
//
import UIKit
@Jesse-calkin
Jesse-calkin / color_management.md
Created March 23, 2016 19:46
Color Management

Color Management

Base Colors

public struct Colors {
    public static let blue1 = UIColor(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
    public static let blue2 = UIColor(red: 0.0, green: 0.4, blue: 1.0, alpha: 1.0)
    public static let blue3 = UIColor(red: 0.1, green: 0.0, blue: 1.0, alpha: 1.0)
 public static let blue4 = UIColor(red: 0.2, green: 0.2, blue: 1.0, alpha: 1.0)
//
// DonutView.swift
//
// Created by jesse calkin on 3/15/16.
// Copyright © 2016 jesse calkin. All rights reserved.
//
import UIKit
func percentToRadians(percent: CGFloat) -> CGFloat {
import UIKit
import XCPlayground
let page = XCPlaygroundPage.currentPage
let view = UIView(frame: CGRect(x: 0, y: 0, width: 750, height: 750))
page.liveView = view
let position = CGPoint(x: 0, y: 0)
@Jesse-calkin
Jesse-calkin / ViewPagerTabs.swift
Last active April 20, 2016 16:45
An iOS version of the tabs used with Android's view pager, based on a UISegmentedControl
//
// ViewPagerTabs.swift
//
// Created by jesse calkin on 3/14/16.
// Copyright © 2016 Shoshin Boogie. All rights reserved.
//
import UIKit
class ViewPager: UISegmentedControl {