Skip to content

Instantly share code, notes, and snippets.

View earltedly's full-sized avatar

Ted Bradley earltedly

View GitHub Profile
/*{
"author": "Ted Bradley",
"targets": ["omnifocus"],
"type": "action",
"identifier": "com.tedbradley.Move to DT",
"version": "0.1",
"description": "Moves the current task to the DevonThink global inbox",
"label": "Move to DT",
"mediumLabel": "Move to DevonThink",
"paletteLabel": "Move to DT",
import Foundation
// Version 1
struct Version: Codable {
let name: String
}
// This is a compacted JSON string of version 1
let encoded = try! JSONEncoder().encode(Version1(name: "Hello"))
@earltedly
earltedly / commonprofile.metal
Created September 27, 2019 14:33 — forked from j-j-m/commonprofile.metal
Can't access GL Uniforms in Metal shader modifier? Apple docs for SCNShadable written in terms of GL? Pulling your hair out?... this will help.
////////////////////////////////////////////////
// CommonProfile Shader v2
#import <metal_stdlib>
using namespace metal;
#ifndef __SCNMetalDefines__
#define __SCNMetalDefines__
@earltedly
earltedly / commonprofile.metal
Created September 27, 2019 14:32 — forked from j-j-m/commonprofile.metal
Can't access GL Uniforms in Metal shader modifier? Apple docs for SCNShadable written in terms of GL? Pulling your hair out?... this will help.
////////////////////////////////////////////////
// CommonProfile Shader v2
#import <metal_stdlib>
using namespace metal;
#ifndef __SCNMetalDefines__
#define __SCNMetalDefines__

New Features in beta 3

  • You can use an unlimited number of Swift files in a target if you set the build setting USE_SWIFT_RESPONSE_FILE to YES. (35879960)

  • Object detection and text classification templates are available in Create ML, joining the image classification and sound classification templates. Use these templates starting with macOS 10.15 beta 3. (52009035)

  • You can now classify sounds live directly from the microphone using Sound Classification preview. (52131594)

  • The view debugger now shows the names of NSImageinstances in the inspector. (35516797)

@earltedly
earltedly / flicks.swift
Created February 25, 2019 13:28
Example implementation of Flicks for macOS/iOS
import Foundation
import CoreMedia
// CMTimeScale is a typealias for Int32
enum Flicks {
static let timescale = CMTimeScale(integerLiteral: 705600000)
}
// CMTime is used throughout AVFoundation & other media APIs
extension CMTime {
import Foundation
import RxSwift
import RxCocoa
class ImageCache {
static let sharedInstance = ImageCache()
private let observableCache = NSCache()
private let imageCache = NSCache()
@earltedly
earltedly / NSInputStream+String.swift
Last active July 23, 2016 09:42
Read an NSInputStream into a String
extension NSInputStream
{
public func readString(bufferSize: Int = 4096) -> String {
guard let data = NSMutableData(capacity: bufferSize) else { return "" }
let buffer = UnsafeMutablePointer<UInt8>.alloc(bufferSize)
var bytesRead = 0
repeat {
bytesRead = read(buffer, maxLength: bufferSize)
data.appendBytes(buffer, length: bytesRead)
//: Playground - noun: a place where people can play
import UIKit
protocol Foo {
}
protocol Bar {
@earltedly
earltedly / stacktrace.swift
Created September 8, 2015 15:50
One line stack trace in Swift
NSThread.callStackSymbols().reduce("") { "\($0)\n\($1 as! String)" }