Skip to content

Instantly share code, notes, and snippets.

View dbettermann's full-sized avatar

Dylan Bettermann dbettermann

View GitHub Profile
@dbettermann
dbettermann / Screenshot.swift
Last active April 18, 2019 16:53
Take screenshot that includes status bar
extension UIScreen {
class func screenshot() -> UIImage {
let view = mainScreen().snapshotViewAfterScreenUpdates(false)
UIGraphicsBeginImageContext(view.bounds.size)
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
let screenshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
@dbettermann
dbettermann / gist:88d0e7e5264bb0640056
Created March 6, 2015 23:45
Only allow numbers and backspaces in UITextField
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
return string.toInt() != nil || string.isEmpty
}
@dbettermann
dbettermann / gist:03f295528843d5425c76
Created January 31, 2015 22:48
String Extension - Ordinal number formatting
extension String {
static func ordinalNumberFormat(number: Int) -> String {
var ending = "th"
let ones = number % 10
let tens = ((number / 10) % 10) as Int
if tens != 1 { // tens == 1 will always end in "th"
switch ones {
2012-10-31 00:07:45,779 (1bc8) : DEBUG (runtime:655) - Handling request GET /:/plugins/com.plexapp.agents.localmedia/messaging/function/X0FnZW50S2l0OlNlYXJjaA__/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoyCmRpY3QKZGljdAo0CnMyCmVuczQKbGFuZ3M3ClRWX1Nob3dzMTAKbWVkaWFfdHlwZWIwczYKbWFudWFscjEKczYKa3dhcmdzMwpzNDIKY29tLnBsZXhhcHAuYWdlbnRzLnRoZXR2ZGI6Ly83NTc2MD9sYW5nPWVuczQKZ3VpZGIxczUKZm9yY2VzMjYKY29tLnBsZXhhcHAuYWdlbnRzLnRoZXR2ZGJzMTMKcHJpbWFyeV9hZ2VudHIwCg__
2012-10-31 00:07:45,779 (1bc8) : DEBUG (runtime:751) - Found route matching /:/plugins/com.plexapp.agents.localmedia/messaging/function/X0FnZW50S2l0OlNlYXJjaA__/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoyCmRpY3QKZGljdAo0CnMyCmVuczQKbGFuZ3M3ClRWX1Nob3dzMTAKbWVkaWFfdHlwZWIwczYKbWFudWFscjEKczYKa3dhcmdzMwpzNDIKY29tLnBsZXhhcHAuYWdlbnRzLnRoZXR2ZGI6Ly83NTc2MD9sYW5nPWVuczQKZ3VpZGIxczUKZm9yY2VzMjYKY29tLnBsZXhhcHAuYWdlbnRzLnRoZXR2ZGJzMTMKcHJpbWFyeV9hZ2VudHIwCg__
2012-10-31 00:07:45,779 (1bc8) : INFO (agentkit:914) - Searching for matches for {'guid': 'com.plexapp.agents.t