Skip to content

Instantly share code, notes, and snippets.

View irace's full-sized avatar

Bryan Irace irace

View GitHub Profile
@irace
irace / gif.sh
Created January 30, 2017 23:40
GIF.sh
#!/bin/bash
#
# A simple script to generate an animated gif from an mp4 file.
#
# Some notes:
# - To use this you need both ffmpeg and imagemagick installed. You can 'brew install' both of them.
# - Our version of github enterprise has a 10MB size limit per file. Make sure your gifs are below that limit.
#
# This is based on https://gist.github.com/dergachev/4627207
#
@irace
irace / Keychain.swift
Created November 16, 2016 15:18
Swift Keychain
import Foundation
import Result
import Security
/**
* A simple wrapper around the Security framework’s keychain functions, providing a Swifty-er API.
*/
typealias KeychainQuery = [String: Any]
struct Keychain {
@irace
irace / music.md
Created September 19, 2016 21:17
Spotify vs. Apple Music
Spotify Apple Music
Amazon Echo integration Offline Apple Watch playback
Smart playlists
@irace
irace / Optional+Empty.swift
Last active June 16, 2016 16:17
`UITextView` should really just have this by default.
protocol TextContaining {
var isEmpty: Bool { get }
}
extension String: TextContaining {
}
extension Optional where Wrapped: TextContaining {
var isEmpty: Bool {
switch self {
@irace
irace / gist:27c72d538b02d33cd714
Last active May 17, 2016 22:02
CSS and JavaScript from Tumblr 3.0 for iOS (Summer 2012)
// Copyright (c) 2012 Tumblr. All rights reserved.
// License: Apache 2.0
// We're using an 'active' class instead of the default :active pseudo selector because we can add/remove it easily
var elementsWithActiveStateSelector = ['.tumblelog', '.control', '.audio-player', '.tag', 'a', '.video',
'.gif-container', '.external-image-placeholder'].join(',');
$('#content').on('touchstart', elementsWithActiveStateSelector, function() {
var $el = $(this);
@irace
irace / Protocol inheritance.swift
Created May 11, 2016 14:24
Works in a playground, does not work in a project file as of Xcode 7.3.1
protocol Foo {
}
extension Foo {
func bar() -> Self { return self }
}
extension NSObject: Foo {}
let view = UIView().bar() // Value of type `UIView` has no member `bar`
@irace
irace / sound.md
Last active March 23, 2016 17:29
Ideal iOS notifications/sounds setup
  1. When volume switch is On, phone both makes noise and vibrates.

  2. When volume switch is Off, phone does not make noise or vibrate.

  3. Calls should make noise/vibrate in extenuating cirumstances, e.g. a call from a favorite or two calls within three minutes.

Vibrate on Silent accomplishes 1 and 2, but prevents 3 from occurring.

3 could be accomplished by ignoring the volume switch altogether and using Do Not Disturb to solely determine whether my phone is silent or not. In this case, I would have DND turned on almost all of the time. The problem with this is that when the phone is unlocked/in use, notifications will either A) not be shown at all or B) will cause noise/vibration.

@irace
irace / gist:3363569
Created August 15, 2012 20:54
Generate iOS Localizable.strings format from PO file
#!/usr/bin/python
import sys
if __name__ == '__main__':
filename = sys.argv[1];
input = open(filename)
output = open(filename + '.out', 'w')
for line in input:
@irace
irace / checklist.md
Created October 29, 2015 21:16
iOS development checklist

Qualifies

Already had

  • Accessibility
  • Handoff
  • Safari Shared Credentials
  • iCloud Keychain
  • iPad Multitasking
  • State Restoration
@irace
irace / ViewControllerSequence.swift
Created January 8, 2016 21:58
Trying to model a sequence of view controllers.
struct ViewControllerSequence {
typealias ViewControllerProducer = Void -> UIViewController
private var storage = TypeDictionary<ViewControllerProducer>()
private var producers: [ViewControllerProducer]
init(_ producers: [ViewControllerProducer]) {
self.producers = producers
}