Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick B. Gibson patr1ck

  • Portland, OR
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am patr1ck on github.
  • I am patr1ck (https://keybase.io/patr1ck) on keybase.
  • I have a public key whose fingerprint is 198B 2618 BC9C 418D 0AEB 0A7C 145B D15C 8361 DB5B

To claim this, I am signing this object:

@patr1ck
patr1ck / ternary.swift
Created Jan 2, 2017
Ternary Swift 3 Operators Example
View ternary.swift
import Foundation
precedencegroup GreaterBPrecedence {
associativity: left
higherThan: LogicalConjunctionPrecedence
}
precedencegroup EqualBPrecedence {
associativity: left
higherThan: GreaterBPrecedence
@patr1ck
patr1ck / Additions.swift
Created Aug 25, 2016
Swift (2.3) Snippets
View Additions.swift
extension CollectionType {
/// Returns the element at the specified index iff it is within bounds, otherwise nil.
subscript (safe index: Index) -> Generator.Element? {
return indices.contains(index) ? self[index] : nil
}
}
extension Int {
func times(thing: Void -> Void) -> Void {
for _ in 0..<self {
@patr1ck
patr1ck / KeyboardListener.swift
Last active Feb 21, 2018
A simple extension for handling keyboard shows/hides
View KeyboardListener.swift
//
// KeyboardListener.swift
//
// Created by Patrick B. Gibson on 7/16/16.
//
import UIKit
protocol KeyboardListener: AnyObject {
var view: UIView! { get }
@patr1ck
patr1ck / main.swift
Last active Aug 25, 2016
Polymorphic Function Returns in Swift
View main.swift
// In Swift, functions can be defined with identical parameter types, but different return types.
func isHello(string: String) -> Bool {
if string == "Hello" {
return true
} else {
return false
}
}
View keybase.md

Keybase proof

I hereby claim:

  • I am patr1ck on github.
  • I am patr1ck (https://keybase.io/patr1ck) on keybase.
  • I have a public key whose fingerprint is 2BF0 3AAF EB33 4E47 C823 2F1F 98D8 5AFE 2729 A3D5

To claim this, I am signing this object:

@patr1ck
patr1ck / Info.plist
Created Jun 19, 2013
This script open all videos on the developer.apple.com/wwdc/videos page. Put these two files in a directory called WWDCAccordionSmash.safariextz, and open in Safari.
View Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Author</key>
<string>Patrick B. Gibson</string>
<key>Builder Version</key>
<string>8536.30.1</string>
<key>CFBundleDisplayName</key>
<string>WWDC Accordion Smash</string>
You can’t perform that action at this time.