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 / 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?
@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 / 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 / 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$
@justinlevi
justinlevi / Behat.feature
Created February 25, 2016 20:10
PHPStorm File and Code Templates - Behat
Feature: #[[$Title$]]#
#[[$END$]]#
@justinlevi
justinlevi / install-composer-drush.sh
Last active June 1, 2016 14:35 — forked from matthewpizza/install-composer.sh
Install Composer on Webfaction
cd $HOME
ln -s `which php56` ~/bin/php
export PATH=$HOME/bin:$PATH
curl -sS https://getcomposer.org/installer | php56
echo -e "\n# Composer\nalias composer=\"php56 \$HOME/composer.phar\"" >> $HOME/.bash_profile
echo -e "\n# Load $HOME/bin\nexport PATH=$HOME/bin:$PATH" >> $HOME/.bash_rc
composer global require drush/drush
ln -s ~/.composer/vendor/drush/drush/drush ~/bin/composer
export DRUSH_PHP=$(which php56)
source $HOME/.bash_profile