Skip to content

Instantly share code, notes, and snippets.

View soffes's full-sized avatar

Sam Soffes soffes

View GitHub Profile
@soffes
soffes / convert.rb
Created August 7, 2015 23:17
Convert old DVR cassettes to the new format
require 'json'
require 'base64'
unless input = ARGV.first
puts 'Run with `ruby convert.rb path_to_your_cassette.json`' and return
end
def process(r)
return unless r && (body = r['body']) && (content_type = r['headers']['Content-Type'])
if content_type.start_with?('text/')
@soffes
soffes / UIColorExtension.swift
Created July 21, 2015 15:48 — forked from asarode/UIColorExtension.swift
Swift extension to get luma value of a UIColor
import UIKit
extension UIColor {
var luminance: CGFloat {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
getRed(&red, green: &green, blue: &blue, alpha: nil)
import Foundation
extension String {
var isHomogeneous: Bool {
if lengthOfBytesUsingEncoding(NSUTF8StringEncoding) == 0 {
return true
}
var homogeneous = true
var character: NSString?
@soffes
soffes / optional_protocol.swift
Last active January 6, 2024 07:22
Checking for the presence of an optional method in a protocol
import Foundation
@objc protocol Foo {
optional func say() -> String
}
class Doesnt: NSObject, Foo {
}
class Does: NSObject, Foo {
@soffes
soffes / Predictions.markdown
Last active August 29, 2015 14:20
Redacted for Mac opening day sales predictions
@soffes
soffes / Mixpanel.swift
Last active August 30, 2016 18:47
Simple Mixpanel event tracking in Swift
// Moved to https://github.com/soffes/Mixpanel
@soffes
soffes / Bond.markdown
Created January 30, 2015 16:47
James Bond Movies

James Bond Movies

Sean Connery

  • Dr. No
  • From Russia with Love
  • Goldfinger
  • Thunderball
  • You Only Live Twice
  • Diamonds Are Forever
@soffes
soffes / NSRange.swift
Created December 23, 2014 14:54
Swift Extensions
//
// NSRange.swift
// MarkdownKit
//
// Created by Sam Soffes on 12/23/14.
// Copyright (c) 2014 Nothing Magical Inc. All rights reserved.
//
import Foundation
//
// CommandClickGestureRecognizer.swift
// Whiskey
//
// Created by Sam Soffes on 12/7/14.
// Copyright (c) 2014 Nothing Magical Inc. All rights reserved.
//
import Cocoa
@soffes
soffes / Gemfile
Last active August 29, 2015 14:06
Roon's Gemfile
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.6'
gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'master'
gem 'puma'
gem 'pg'