Skip to content

Instantly share code, notes, and snippets.

Avatar
😴
I'm probably napping

Matt Moriarity mjm

😴
I'm probably napping
View GitHub Profile
@mjm
mjm / main.go
Created Mar 21, 2019
Instant clone a vSphere VM
View main.go
package main
import (
"context"
"flag"
"fmt"
"net"
"net/url"
"os"
"path"
@mjm
mjm / ManagedObjectChangesPublisher.swift
Created Nov 3, 2019
Observe changes to a Core Data fetch request with Combine
View ManagedObjectChangesPublisher.swift
import Combine
import CoreData
extension NSManagedObjectContext {
func changesPublisher<Object: NSManagedObject>(for fetchRequest: NSFetchRequest<Object>)
-> ManagedObjectChangesPublisher<Object>
{
ManagedObjectChangesPublisher(fetchRequest: fetchRequest, context: self)
}
}
@mjm
mjm / LinkedText.swift
Created May 21, 2020
Tappable links in SwiftUI Text view
View LinkedText.swift
import SwiftUI
private let linkDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
struct LinkColoredText: View {
enum Component {
case text(String)
case link(String, URL)
}
@mjm
mjm / Observables.swift
Created Jul 3, 2020
StateObject vs. ObservableObject
View Observables.swift
// If you run this in a playground in Xcode 12, you can see the difference in behavior in the live view.
import SwiftUI
import PlaygroundSupport
class Counter: ObservableObject {
@Published var count: Int
init(_ initialCount: Int) {
self.count = initialCount
You can’t perform that action at this time.