This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
class MyObserableObject: ObservableObject { | |
@Published var myData: [Int] = [] | |
private var subscription: AnyCancellable? | |
init() { | |
subscription = Timer | |
.TimerPublisher(interval: 1, runLoop: RunLoop.main, mode: .default) | |
.map { _ -> AnyPublisher<[Int], Never> in | |
URLSession |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import CoreData | |
struct SearchableGrid<T: NSManagedObject, Content: View, EmptyContent: View>: View where T: Identifiable { | |
@Environment(\.managedObjectContext) var context | |
@StateObject private var viewModel = SearchableGridGridViewModel<T>() | |
let dropEntered : (DropInfo, SearchableGridGridViewModel<T>, T) -> () | |
let dropUpdated : ((DropInfo, T) -> DropProposal?)? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Capsule() | |
.fill(Color.green) | |
.overlay( | |
Capsule() | |
.stroke(Color.black, lineWidth: 10) | |
) | |
.frame(width: 200, height: 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getDocumentsDirectory()-> URL { | |
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) | |
let documentsDirectory = paths[0] | |
return documentsDirectory | |
} | |
// MARK: - Core Data stack | |
lazy var persistentContainer: NSPersistentContainer = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Emoji Packs | |
extension Emoji { | |
private func getEmojiFileName(for pack: String) -> String { | |
let strArr = codePoints | |
.compactMap({ String(format:"%04X", UInt32($0)) }) | |
.joined(separator: "-") | |
.lowercased() | |
return strArr + ".svg" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in *.svg ; do rsvg-convert -d 500 -w 300 "$i"> "$i".png ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UniformTypeIdentifiers | |
struct GridData: Identifiable, Equatable { | |
let id: String | |
} | |
//MARK: - Model | |
class Model: ObservableObject { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
func convertViewToData<V>(view: V, size: CGSize, completion: @escaping (Data?) -> Void) where V: View { | |
guard let rootVC = UIApplication.shared.windows.first?.rootViewController else { | |
completion(nil) | |
return | |
} | |
let imageVC = UIHostingController(rootView: view.edgesIgnoringSafeArea(.all)) | |
imageVC.view.frame = CGRect(origin: .zero, size: size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup plotting | |
import matplotlib.pyplot as plt | |
from learntools.deep_learning_intro.dltools import animate_sgd | |
plt.style.use('seaborn-whitegrid') | |
# Set Matplotlib defaults | |
plt.rc('figure', autolayout=True) | |
plt.rc('axes', labelweight='bold', labelsize='large', | |
titleweight='bold', titlesize=18, titlepad=10) | |
plt.rc('animation', html='html5') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SwipeableModifier.swift | |
// DrinkSum | |
// | |
// Created by Greg Eales on 22/12/20. | |
// | |
import SwiftUI | |
struct Swipeable<V>: ViewModifier where V: View { |
NewerOlder