Skip to content

Instantly share code, notes, and snippets.

@rustle
rustle / gist:4342284
Created December 20, 2012 01:30
Cornerstone with Kaleidoscope 2 beta

Cornerstone does not yet officially support Kaleidoscope 2, so to work with the latest beta of Kaleidoscope 2 (Build 99 and up) here is how to get set up:

Follow the instructions here Cornerstone External Compare Tools under the heading Custom Compare Scripts

The custom scripts contents should be

#!/usr/bin/env bash

/usr/local/bin/ksdiff --partial-changeset -- "$1" "$2"
@available(iOS 16.0, macOS 13.0, watchOS 9.0, *)
@propertyWrapper
public struct AsyncPublished<Value> {
@available(*, unavailable, message: "@AsyncPublished is only available on properties of classes")
public var wrappedValue: Value {
get { fatalError() }
set { fatalError() } // swiftlint:disable:this unused_setter_value
}
public let projectedValue: AsyncStream<Value>
public init(initialValue: Value) {
@rustle
rustle / gist:4115414
Created November 20, 2012 01:45
Source Tree with Kaleidoscope 2 beta

SourceTree does not yet officially support Kaleidoscope 2, so here is how to set it up:

In Preferences, under Diff:

Screen Shot

You can try selecting Kaleidoscope, but we have had reports of mixed results. Some people have rebuilt their launch services database and restarted and been able to use Kaleidoscope this way:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain use

import Foundation
/*
Somewhere in Foundation
public protocol Foo {
...
public init<T>?(foo value: T) where T: Foo
...
}
protocol Example {
associatedtype Value
func value() -> Value
}
struct AnyExample<Value> {
private class Container<Value> {
func value() -> Value {
fatalError()
}
@propertyWrapper
struct ErasedToAnyPublisher<Upstream: Publisher> {
var wrappedValue: AnyPublisher<Upstream.Output, Upstream.Failure> {
upstream.eraseToAnyPublisher()
}
let upstream: Upstream
init(upstream: Upstream) {
self.upstream = upstream
}
}
public extension Publisher {
/// Assigns each element from a Publisher to a property on an object.
///
/// - Parameters:
/// - keyPath: The key path of the property to assign.
/// - object: The object on which to assign the value.
/// - Returns: A cancellable instance; used when you end assignment of the received value. Deallocation of the result will tear down the subscription stream.
func assignResult<Root>(to keyPath: ReferenceWritableKeyPath<Root, Result<Self.Output, Self.Failure>>,
on object: Root) -> AnyCancellable {
sink(receiveCompletion: { completion in
class Foo {
var body: some View {
...
}
}
class Bar: Foo {
override var body: some View {
...
}
//
// BoundedQueue.swift
//
// Copyright © 2017 Doug Russell. All rights reserved.
//
import Foundation
public class BoundedQueue {
private let group = DispatchGroup()
@rustle
rustle / gist:6618451
Created September 19, 2013 02:32
A __attribute__ decorator that causes method calls to become implicit dispatches could be interesting: __attribute__((dispatch, async, priority))
#import <Foundation/Foundation.h>
#include <objc/message.h>
typedef void (*DISPATCH_IMP_NOARGS_NORETURN)(id, SEL);
typedef id (*DISPATCH_IMP_NOARGS)(id, SEL);
@interface Foo : NSObject
@end