Skip to content

Instantly share code, notes, and snippets.

@loganwright
loganwright / Readme.md
Last active August 4, 2023 03:50
UIView Gesture Recognizer Extension For Swift

Interface for dealing with gesture recognizers via native swift closure syntax

import UIKit

class ViewController: UIViewController {
                            
    override func viewDidLoad() {
        super.viewDidLoad()
 view.addSingleTapGestureRecognizerWithResponder { (tap) -> Void in
@loganwright
loganwright / probability.swift
Last active June 24, 2021 23:56
binary-cards-probability
// setup
enum Value: String, CaseIterable, Equatable {
case ace,
two,
three,
four,
five,
six,
seven,
@loganwright
loganwright / SetupCocoaPods.md
Last active August 28, 2020 16:39
Setting Up Cocoapods Guide

#Cocoapods

##Installing Cocoapods

  • Open Terminal
  • Enter command: sudo gem install cocoapods
  • Enter your password

Wait for this to finish, don't touch your terminal. It might take a couple minutes

@loganwright
loganwright / dontencode.swift
Created May 7, 2020 13:02
Swift Encodable Dont Encode
@propertyWrapper
struct DontEncode<T: Codable> {
var wrappedValue: T
}
extension DontEncode: Codable {
init(from decoder: Decoder) throws {
self.wrappedValue = try T(from: decoder)
}
import Foundation
extension Dictionary {
mutating public func setValue(val: AnyObject, forKeyPath keyPath: String) {
var keys = keyPath.componentsSeparatedByString(".")
guard let first = keys.first as? Key else { print("Unable to use string as key on type: \(Key.self)"); return }
keys.removeAtIndex(0)
if keys.isEmpty, let settable = val as? Value {
self[first] = settable
} else {
@loganwright
loganwright / xcshortcuts.md
Created June 9, 2015 15:39
Xcode Shortcuts

##Useful Shortcuts

Here's a pretty decent reference as well: http://i.stack.imgur.com/Buohl.jpg

###Must Haves!

cmd + shift + o -- quick navigator -- works with classes, structs, functions, etc.

cmd + shift + j -- Show current file in navigator. Pairs well w/ quick navigator to see where the file fits into the full app.

@loganwright
loganwright / Contact.swift
Created January 9, 2015 19:03
SwiftContact - Converting ABRecordRef to Clean, usable contact object
//
// Contact.swift
// FriendLender
//
// Created by Logan Wright on 9/22/14.
// Copyright (c) 2014 lowriDevs. All rights reserved.
//
import UIKit
import AddressBook
@loganwright
loganwright / Picker.swift
Created June 2, 2015 02:54
Swift Generic UIPickerView
class PickerSource : NSObject, UIPickerViewDelegate, UIPickerViewDataSource {
var data: [[String]] = []
var selectionUpdated: ((component: Int, row: Int) -> Void)?
// MARK: UIPickerViewDataSource
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return data.count
}
@loganwright
loganwright / vapor-three.md
Last active July 21, 2017 17:29
Vapor 3.0 - Swift 4 Checklist

Bits

  • MacOS (07-10)
  • Linux (07-20 | 16.04)

Debugging

  • MacOS (07-10)
  • Linux (07-20 | 16.04)
@loganwright
loganwright / docker.md
Last active April 30, 2017 02:56
Docker

Dockerfile

FROM ibmcom/swift-ubuntu:latest

# Install Vapor Toolbox
RUN curl -sL toolbox.vapor.sh | bash

# Set work dir to /vapor
WORKDIR /vapor