This file contains hidden or 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 | |
| extension JSONConvertible { | |
| func toJSONString() -> String? { | |
| return (try? JSONSerialization.data(withJSONObject: toDictionary(), options: [])) | |
| .flatMap { String(data: $0, encoding: .utf8) } | |
| } | |
| static func fromJSONString(_ jsonString: String) -> Self? { | |
| return (try? JSONSerialization.jsonObject(with: Data(jsonString.utf8), options: [])) |
This file contains hidden or 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
| // | |
| // ContentView.swift | |
| // SpotlightAppSearch | |
| // | |
| // Created by seoksoon jang on 2023-05-06. | |
| // | |
| import SwiftUI | |
| import CoreServices |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |