Instantly share code, notes, and snippets.

Tyler Stromberg AquaGeek

View GitHub Profile
View L10n.swift
struct L10n {
struct Login {
static func welcomeMessage(placeholder: String) -> String {
return String.localizedStringWithFormat(
NSLocalizedString("login.welcome_message", "Greeting to show users upon successful login"),
View ColorExtensions.swift
extension NSColor {
// Derived from logic in TextMate
func soften(color inColor: NSColor, factor: CGFloat) -> NSColor {
guard let color = inColor.usingColorSpace(NSColorSpace.sRGB) else {
return inColor
var red = color.redComponent
var green = color.greenComponent
var blue = color.blueComponent

Override stupid system default that disables state restoration.

UserDefaults.standard.set(true, forKey: "NSQuitAlwaysKeepsWindows")  // override stupid global preference, so our state restore works properly



Adding "ownership" to Swift is a major feature with many benefits for programmers. This document is both a "manifesto" and a "meta-proposal" for ownership: it lays out the basic goals of the work, describes a general approach for achieving those goals, and proposes a number of specific changes and features, each of which will need to be separately discussed in a smaller and more

View Rx.swift
// Retry with backoff
// Adapted from
.range(start: 1, count: 10)
.doOn(onNext: { i in
if i == 5 {
throw NSError(domain: "com.example", code: 1, userInfo: ["any": "thing"])
.retryWhen { (attempts: Observable<ErrorType>) -> Observable<Int64> in
View Storyboards.swift
// FROM:
protocol StoryboardInstantiable {
typealias ViewController
static var storyboardID: String { get }
static func instance(storyboard: UIStoryboard) -> ViewController?
extension StoryboardInstantiable {
static func instance(storyboard: UIStoryboard) -> ViewController? {
return storyboard.instantiateViewControllerWithIdentifier(Self.storyboardID) as? ViewController
View AdjacentList.m
@interface TSGraph : NSObject
- (void)addEdgeFrom:(id)vertexA to:(id)vertexB;
@implementation TSGraph
NSMutableDictionary *_vertices;
View main.m
@import Foundation;
int main(int argc, const char * argv[])
__block BOOL keepRunning = YES;
// Configure a dispatch source to listen for SIGTERM
// Adapted from
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue());
dispatch_source_set_event_handler(source, ^{
View LRUCache.swift
private class LRUCacheNode<Key: Hashable, Value> {
let key: Key
var value: Value
var previous: LRUCacheNode?
var next: LRUCacheNode?
init(key: Key, value: Value) {
self.key = key
self.value = value
View heroku-addons.rb
require 'uri'
require 'net/http'
require 'json'
require 'ostruct'
module Heroku
module Addons
class Addon
attr_accessor :name