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 WebKit | |
@main | |
struct MonacoApp: App { | |
let codeSnippet = """ | |
var body: some Scene { | |
WindowGroup { | |
EditorView(content: codeSnippet, language: "swift", theme: "vs-dark") | |
} |
This file has been truncated, but you can view the full file.
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
// written by https://talk.objc.io/episodes/S01E211-simple-fuzzy-matching | |
// credits should go to obj.io | |
import SwiftUI | |
import Cocoa | |
struct ContentView: View { | |
@State var needle: String = "" | |
var filtered: [(string: String, indices: [String.Index])] { |
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 Foundation | |
func loop(_ count: Int, body: @escaping ((Range<Int>.Element)) throws -> Void) rethrows { | |
try (0..<count).forEach(body) | |
} | |
func loop(_ count: Int, body: @escaping (() throws -> Void)) rethrows { | |
(0..<count).forEach { _ in | |
try? body() | |
} |
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 <Carbon/Carbon.h> | |
#import <dlfcn.h> | |
/* | |
* Returns an array of CFDictionaryRef types, each of which contains information about one of the processes. | |
* The processes are ordered in front to back, i.e. in the same order they appear when typing command + tab, from left to right. | |
* See the ProcessInformationCopyDictionary function documentation for the keys used in the dictionaries. | |
* If something goes wrong, then this function returns NULL. | |
*/ | |
CFArrayRef CopyLaunchedApplicationsInFrontToBackOrder(void) |
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 Foundation | |
class Class { | |
func log2() { | |
print("class log2") | |
} | |
func log3() { | |
print("class log3") | |
} |
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 Foundation | |
class Class { | |
var i = 0 | |
func decrease() { | |
i-=1 | |
} | |
func increase() { |
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 Foundation | |
class Class { | |
var i = 0 | |
func decrease() { | |
i-=1 | |
} | |
func increase() { |
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
;; https://clojure-doc.org/articles/language/interop/ | |
(doto (java.util.Stack.) | |
(.push 42) | |
(.push 13) | |
(.push 7)) ; ⇒ #<Stack [42, 13, 7]> | |
(.. (java.util.Date.) | |
getTime | |
toString) |
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 Foundation | |
// reference: https://www.swiftbysundell.com/articles/delaying-an-async-swift-task/ | |
let loadingSpinnerTask = Task.delayed(byTimeInterval: 0.15) { | |
self.showLoadingSpinner() | |
} | |
Task { | |
await a() |
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 Foundation | |
// < iOS 16 | |
var task: Task<(), Never>? | |
func debounce(seconds: Double = 1.0, | |
operation: @escaping () -> Void) { | |
task?.cancel() |