Skip to content

Instantly share code, notes, and snippets.

@justinlevi
justinlevi / gist:89da0206bbf461aad745
Created June 26, 2015 20:34
Swift 2 Xcode Beta 2 - Ole Begemann Post Sytax Update
public enum PathElement {
case MoveToPoint(CGPoint)
case AddLineToPoint(CGPoint)
case AddQuadCurveToPoint(CGPoint, CGPoint)
case AddCurveToPoint(CGPoint, CGPoint, CGPoint)
case CloseSubpath
init(element: CGPathElement) {
switch element.type {
case .MoveToPoint:
@justinlevi
justinlevi / CAToneFileGeneratorSwift
Last active November 18, 2020 15:58
Swift CAToneFileGenerator "Learning Core Audio" Example
//: Playground - noun: a place where people can play
import UIKit
import Foundation
import AudioToolbox
import AVFoundation
import XCPlayground
func CheckError(error:OSStatus) {
if error == 0 {return}
@justinlevi
justinlevi / PHImageRequest Extension
Last active November 4, 2015 01:38
PHImageRequest convenience Initializer Extension
extension PHImageRequestOptions {
convenience init(deliveryMode: PHImageRequestOptionsDeliveryMode, resizeMode: PHImageRequestOptionsResizeMode){
self.init()
self.deliveryMode = deliveryMode
self.resizeMode = resizeMode
}
@justinlevi
justinlevi / swift-kvo-example.swift
Created November 11, 2015 21:36 — forked from correia/swift-kvo-example.swift
A quick example for how to use Foundation style KVO from Swift. (Official documentation from Apple is forthcoming.)
//
// Swift-KVO
//
// Created by Jim Correia on 6/5/14.
// Copyright (c) 2014-2015 Jim Correia. All rights reserved.
//
// Update: 6/17/2014
//
// KVOContext has gone away; use the same idiom you'd use from Objective-C for the context
//
import Foundation
// ============================================
// MARK: - KVObserver Helper
// Modified from Source : https://stackoverflow.com/questions/27292918
class KVObserver: NSObject {
private let keyPath: String
private let block: () -> Void
private weak var object: AnyObject?
//
// RBResizer.swift
// Locker
//
// Created by Hampton Catlin on 6/20/14.
// Copyright (c) 2014 rarebit. All rights reserved.
// Updated by Justin Winter on 11/29/15.
//
extension UIImage {
@justinlevi
justinlevi / ft
Last active February 25, 2016 19:49
PHPStorm Behat LiveTemplate Feature
In order to $Value$
As a $Role$
I need to $Description$
$END$
@justinlevi
justinlevi / ftc
Created February 25, 2016 19:47
PHPStorm Behat LiveTemplate - Feature Comments
# {A} - the benefit or value of the feature
# - In order to achieve -> Business Value
# {B} - the role (or person) who will benefit
# - as a person who benefits; The "author" of this feature
# {C} - short feature description:
# - Description of the feature, the action the person will take
$END$
@justinlevi
justinlevi / sc
Created February 25, 2016 19:49
PHPStorm Behat LiveTemplate - Scenario
Scenario: $Title$
Given $given$
When $when$
And $and$
Then $then$
@justinlevi
justinlevi / scc
Created February 25, 2016 19:50
PHPStorm Behat LiveTemplate - Scenario Comments
# Given: Defines the inital state of the system for the scenario
# When: Describes the action taken by the person/role
# Then: Describes the obeservable system state after the action has been performed
$END$