Skip to content

Instantly share code, notes, and snippets.

Sam Soffes soffes

Block or report user

Report or block soffes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
soffes /
Created Oct 10, 2019
I'm trying to figure out how Xcode formats floats in its XIB/Storyboard XML. So far, I'm stumped.
import re
# I'm trying to figure out how Xcode formats floats in its XIB/Storyboard XML. So far, I'm stumped.
# Data from Xcode
data = values = ["0.0", "0.0039215686274509803", "0.0078431372549019607", "0.011764705882352941", "0.0039215686274509803", "0.019607843137254902", "0.023529411764705882", "0.027450980392156862", "0.031372549019607843", "0.035294117647058823", "0.039215686274509803", "0.043137254901960784", "0.047058823529411764", "0.050980392156862744", "0.054901960784313725", "0.058823529411764705", "0.062745098039215685", "0.066666666666666666", "0.070588235294117646", "0.074509803921568626", "0.078431372549019607", "0.082352941176470587", "0.086274509803921567", "0.090196078431372548", "0.094117647058823528", "0.098039215686274508", "0.10196078431372549", "0.10588235294117647", "0.10980392156862745", "0.11372549019607843", "0.11764705882352941", "0.12156862745098039", "0.12549019607843137", "0.12941176470588234", "0.13333333333333333", "0.13725490196078433", "0.14117647058823529", "0.1450980392
soffes / highlight.swift
Last active May 20, 2019 — forked from orta/highlight.swift
Swift implementation to highlight Cocoa UI elements (
View highlight.swift
// Taken from:
NSBezierPath(rect: rect).fill()
if rect.height > 1 {
let currentControlTint = NSColor.currentControlTint
let startingAlpha: CGFloat = currentControlTint == .blueControlTint ? 0.16 : 0.09
View Readme.markdown

CFRunLoopSource is cool. It lets you build behavior similar to the mechanisms that drive setNeedsLayout and setNeedsDisplay in UIKit.

I found myself in need of something like this a couple of times. It's great to know that no matter how many times I say I need to update something, I will get a single callback at the end of the run loop that gives me a chance to perform my work.

Here is a little Swift wrapper that makes the API easier to deal with.

Updated for Swift 4

soffes / Vagrantfile
Last active Jul 19, 2017
Vagrantfile for working with Swift
View Vagrantfile
Vagrant.configure(2) do |config| = "boxcutter/ubuntu1610"
config.ssh.pty = true
config.vm.provision "shell", inline: <<-SHELL
su vagrant
sudo apt-get -y update
sudo apt-get install -y git python-dev libcurl3 clang
git clone ~/.swiftenv
echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.bash_profile
soffes / Rakefile
Last active Nov 13, 2019
Programmatically build and sign a Developer ID macOS app
View Rakefile
APP_NAME = 'My App'
desc 'Create a beta build'
task :build do
# Ensure clean git state
unless system 'git diff-index --quiet HEAD --'
abort 'Failed. You have uncommitted changes.'
soffes / BaseTextStorage.swift
Last active Feb 24, 2019
Fast, concrete text storage intended to be subclassed.
View BaseTextStorage.swift
import UIKit
/// Fast, concrete text storage intended to be subclassed.
class BaseTextStorage: NSTextStorage {
// MARK: - Properties
private let storage = NSMutableAttributedString()
// MARK: - NSTextStorage
soffes / WebCredential.swift
Last active Apr 18, 2019
Easily access Shared Web Credentials
View WebCredential.swift
import Foundation
import Security
struct SharedWebCredentials {
// MARK: - Types
struct Credential {
let domain: String
let account: String
soffes / UISplitViewController+Soffes.swift
Created Jun 8, 2016
Easily access master and detail view controllers on UISplitViewController
View UISplitViewController+Soffes.swift
import UIKit
extension UISplitViewController {
convenience init(masterViewController: UIViewController, detailViewController: UIViewController) {
viewControllers = [masterViewController, detailViewController]
var masterViewController: UIViewController? {
return viewControllers.first
View UIColor+Desaturated.swift
import UIKit
extension UIColor {
var desaturated: UIColor {
var hue: CGFloat = 0
var brightness: CGFloat = 0
var alpha: CGFloat = 0
getHue(&hue, saturation: nil, brightness: &brightness, alpha: &alpha)
View gist:3fa2f8fa7ee3bb14225d738aaa42918b
$ git clone
$ cd ISO8601
$ pod trunk push --verbose
[!] Found podspec `ISO8601.podspec`
Updating spec repo `master`
Validating podspec
ISO8601 (0.5.2) - Analyzing on OS X platform.
You can’t perform that action at this time.