Skip to content

Instantly share code, notes, and snippets.

jonathan-beebe / swift-to-objc-bool-bridge.m
Created Dec 22, 2016
Bridging an optional bool from Swift to Objective-C
View swift-to-objc-bool-bridge.m
@implementation MyObjcClass
. . .
if(mySwiftClassInstance.hasFeatureBridged == nil) {
// handle nil case
else if(mySwiftClassInstance.hasFeatureBridged boolValue] == YES) {
// handle true case
jonathan-beebe / Garmin Connect IQ Custom Drawable
Last active Dec 13, 2021
Garmin Connect IQ Custom Drawable
View Garmin Connect IQ Custom Drawable
A sample of creating a custom drawable, both in xml and via code.
jonathan-beebe /
Last active Apr 13, 2021
git: Find all merged ancestors branches and create commands to delete them.

To find all ancestor branches


To create the delete commands for all ancestor branches and echo them as text (not invoking them)

jonathan-beebe / async_xctest.swift
Created Jul 20, 2016
A template for async swift tests
View async_xctest.swift
import XCTest
@testable import {AppTarget}
class TestCase: XCTestCase {
func testCode() {
let expectation = expectationWithDescription("test description")
var result: Bool?
// Setup the the test here
jonathan-beebe /
Created Jul 14, 2016
Fixing nokogiri on OS X 10.12 El Capitan
gem install nokogiri -v '1.6.8' -- --use-system-libraries=true --with-xml2-include=/Applications/
jonathan-beebe / LocalizableButton.swift
Last active Oct 24, 2017
Localizable views in xib or storyboards
View LocalizableButton.swift
import UIKit
/// Implements a UIButton that can be localized within a xib or storyboard.
/// To render a localized string set a “User defined runtime attribute” on
/// the view with a key path of `localizableStringKey` and a string value of
/// the localized string key.
class LocalizableButton: UIButton {
var localizableStringKey: String? {
didSet {
jonathan-beebe / async_helpers.swift
Created May 16, 2016
Helpers to make dispach_* code in Swift a bit more concise.
View async_helpers.swift
import Foundation
func async(callback:(Void -> Void)) {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
func after(delay:Double, closure:Void->Void) {
jonathan-beebe / UICTContentSizeCategory
Created Feb 5, 2016
UICTContentSizeCategory logs for each category
View UICTContentSizeCategory
Caption 1 = {size: 11pts, weight:normal}
default = {size: 13pts, weight:normal}
Body = {size: 14pts, weight:normal}
Subhead = {size: 12pts, weight:normal}
Title 1 = {size: 25pts, weight:normal}
jonathan-beebe /
Last active Nov 30, 2021
Using Apple’s Swift vim plugin with Vundle

Source of original vim config:

# use `svn checkout…` to grab just the subfolder from github
svn checkout
# rename to something a bit more specific
mv vim vim-swift
cd vim-swift
rm -rf .svn
# init git
jonathan-beebe / curried_functions.swift
Last active Dec 21, 2015
curried functions in Swift
View curried_functions.swift
// Here is a manually curried function.
// maxA takes an int and returns a function, maxB, that takes an int and returns an int.
func maxA(a:Int) -> (Int) -> Int {
func maxB(b:Int) -> Int {
return a > b ? a : b
return maxB