Skip to content

Instantly share code, notes, and snippets.

jbrennan / wwdc2014
Created Jul 16, 2019 — forked from phnessu4/wwdc2014
wwdc 2014 sessions and pdf
View wwdc2014
jbrennan / ViewController.swift
Created Aug 31, 2018
Simple file for converting Localizable.strings key=values back into a codebase
View ViewController.swift
class ViewController: NSViewController {
override func viewDidLoad() {
let translations = translationsFor(stringsFilePath: "/Users/jasonbrennan/peloton/Argon/Argon/Supporting Files/Localizable.strings")
for translation in translations {
replace(translation: translation, inProjectDirectory: "/Users/jasonbrennan/peloton/Argon/Argon")
jbrennan / LineScaling.swift
Created Aug 3, 2016
The math behind a “drag to scale this line” operation.
View LineScaling.swift
extension Line {
/** Returns a scaled line according to the projection of `scalingPoint` onto the receiver.
- parameter scalingPoint: A point interpreted as a vector used for scaling this line. This point should be something like the location of a touch or cursor during a "drag to scale" operation, but the point doesn't have to lie along the line itself. The point **must** be in the same coordinate space as the line.
func lineByScalingToTouchPoint(scalingPoint: Point) -> Line {
// This algorithm works by
// - treating the incoming point as a vector,
View Swift

Hello Everyone,

The Swift 3 release is nearing completion, so it is time to look back on the release, learn from what happened, and use it to shape what we (the Swift community) do in the year ahead. Overall, Swift 3 is going to be an absolutely amazing release, and it is impressive how much got done. Thank you to everyone who contributed to making it happen. Instead of diving into a flurry of new proposals immediately, it is important to take stock of where we are, and look at the bigger picture.

Metapoint: this email is ridiculously long and covers multiple topics. Instead of replying to it directly, it is best to start new threads on individual topics that you’d like to discuss. Just tag them with “[Swift 4]” in the subject line.

Swift 3 Retrospective

Every year of Swift’s development has been completely different from the previous one, and I expect Swift 4 to continue this trend. With a goal of learning and improving year over year, here are some observations & retrospective about Swi

jbrennan / nearthespeedoflight-2016.css
Created Apr 3, 2016
Style for April 2 2016
View nearthespeedoflight-2016.css
/* ============================== */
/* ! */
/* ! Speed of Light style ver 3 */
/* ! Copyright 2016 Jason Brennan */
/* ! */
/* ! April 2 2016 */
/* ! */
/* ============================== */
jbrennan / nearthespeedoflight.css
Created Apr 3, 2016
Style for from Feb 2013 to April 2016
View nearthespeedoflight.css
/* ============================== */
/* ! */
/* ! Speed of Light style ver 2.6 */
/* ! Copyright 2011 Jason Brennan */
/* ! */
/* ! February 20 2013 */
/* ! */
/* ============================== */
jbrennan / PrototopeViewController.swift
Created Mar 15, 2016
Example of using setting up Prototope in a UIViewController
View PrototopeViewController.swift
// ViewController.swift
// DrawingProto
// Created by Jason Brennan on 2015-12-19.
// Copyright © 2015 Jason Brennan. All rights reserved.
import UIKit
import Prototope
jbrennan / ImmediatePanGestureRecognizer.m
Created Dec 29, 2015
A UIPanGestureRecognizer subclass to recognize immediately. Is this a good idea?
View ImmediatePanGestureRecognizer.m
@implementation ImmediatePanGestureRecognizer
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
if (self.numberOfTouches >= self.minimumNumberOfTouches) {
self.state = UIGestureRecognizerStateBegan;
jbrennan /
Created Nov 16, 2015
Some notes on getting help with Reactive Cocoa Signals with help from a coworker

Notes about Signals

Nacho offered me a little bit of help today with a relatively simple problem. Here are some notes on it for future reference.

The problem

I have a container view which has in it a TabBarView and a ScrollView. When one of the tabs in the tab bar view is tapped, I want it to update its internal state (which button is selected) and then I need the container view to be able to respond as well (to scroll its scrollview).

jbrennan / Bug.swift
Created Jul 16, 2015
Bug related to having an optional enum in a struct in Swift
View Bug.swift
import Foundation
public struct FeaturedItem {
public enum ImageSource {
case Bundled(name: String) // simplified enum with one case to illustrate the bug.
public let localizedTitleImageSource: ImageSource? // This optional causes Swift to barf. If it's non-optional, it compiles fine
// Workaround in this case is to just use an optional String instead of the enum.