Skip to content

Instantly share code, notes, and snippets.

Avatar
🚐
On the road

Sam Soffes soffes

🚐
On the road
View GitHub Profile
@soffes
soffes / GPUImageTextureInput+CIImage.h
Last active February 26, 2023 14:02
GPUImage + Core Image
View GPUImageTextureInput+CIImage.h
//
// GPUImageTextureInput+CIImage.h
// GPUImage
//
// Created by Sam Soffes on 3/4/14.
// Copyright (c) 2014 Sam Soffes. All rights reserved.
//
#import "GPUImageTextureInput.h"
@soffes
soffes / Rakefile
Last active January 16, 2023 16:37
Programmatically build and sign a Developer ID macOS app
View Rakefile
TEAM_ID = 'XXXXXXXXXX'
APP_NAME = 'My App'
SCHEME_NAME = APP_NAME
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.'
end
@soffes
soffes / CLLocationCoordinate2D+Equatable.swift
Last active December 28, 2022 13:53
Add Equatable to CLLocationCoordinate2D
View CLLocationCoordinate2D+Equatable.swift
import CoreLocation
extension CLLocationCoordinate2D: Equatable {}
public func ==(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool {
return lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude
}
@soffes
soffes / WebCredential.swift
Last active November 25, 2022 08:24
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
soffes / UIFont+Monospaced.swift
Created July 27, 2021 18:17
Monospaced numbers in iOS 15 beta 4
View UIFont+Monospaced.swift
import UIKit
extension UIFont {
public func withMonospacedNumbers() -> Self {
let monospacedFeature: [UIFontDescriptor.FeatureKey: Any]
if #available(iOS 15.0, *) {
monospacedFeature = [
.type: kNumberSpacingType,
.selector: kMonospacedNumbersSelector
@soffes
soffes / Readme.markdown
Created July 3, 2018 23:25 — forked from calebd/Readme.markdown
Run Loop Source
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

View Objective-C Coding Convention and Best Practices.markdown

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@soffes
soffes / SafariActivity.swift
Created October 26, 2020 22:19
Open in Safari UIActivity
View SafariActivity.swift
import UIKit
final class SafariActivity: UIActivity {
// MARK: - Properties
var url: URL?
// MARK: - UIActivity
View canRecordScreen.swift
// From https://stackoverflow.com/a/58985069/118631
@available(macOS 10.15, *)
func canRecordScreen() -> Bool {
let runningApplication = NSRunningApplication.current
let processIdentifier = runningApplication.processIdentifier
guard let windows = CGWindowListCopyWindowInfo([.optionOnScreenOnly], kCGNullWindowID)
as? [[String: AnyObject]] else
{
@soffes
soffes / perferences.json
Created August 22, 2012 05:35
My Sublime Text 2 config
View perferences.json
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/Espresso Soda.tmTheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
".gitkeep",
"dump.rdb"
],