In iTerm2, in the menu bar go to Scripts > Manage > New Python Script
Select Basic. Select Long-Running Daemon
Give the script a decent name (I chose auto_dark_mode.py)
Save and open the script in your editor of choice.
| import SwiftUI | |
| public struct FormattedTextField<Formatter: TextFieldFormatter>: View { | |
| public init(_ title: String, | |
| value: Binding<Formatter.Value>, | |
| formatter: Formatter) { | |
| self.title = title | |
| self.value = value | |
| self.formatter = formatter | |
| } |
| # XTerm Control Sequences based on: | |
| # - https://invisible-island.net/xterm/ctlseqs/ctlseqs.html | |
| # ========================================================================= # | |
| # XTerm Control Sequences from invisible-island.net as pythonic code. | |
| # Basic control sequences are string variables. | |
| # - eg: ESC = '\033' | |
| # CSI = ESC + '[' | |
| # Control sequences that have args can be called to return a string. | |
| # - eg: sgr = CSI + Ps + 'm' |
| struct LazyView<Content: View>: View { | |
| let build: () -> Content | |
| init(_ build: @autoclosure @escaping () -> Content) { | |
| self.build = build | |
| } | |
| var body: Content { | |
| build() | |
| } | |
| } |
| import SwiftUI | |
| /// Example of how to get Dynamic Type with custom fonts in SwiftUI. | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack(spacing: 20) { | |
| Text("A large title").customFont(.largeTitle) // "Optima-ExtraBlack", 28 | |
| Text("A body").customFont(.body) // "Kailasa", 16 | |
| Text("A caption").customFont(.caption2) // "IowanOldStyle-Italic", 11 | |
| } |
| public | |
| extension Sequence | |
| { | |
| /// Returns a Dictionary using the result of `keySelector` as the key, and the result of `valueTransform` as the value | |
| public func associateBy<T, K: Hashable, V>(_ keySelector: (T) -> K, _ valueTransform: (T) -> V) -> [K:V] where T == Iterator.Element | |
| { | |
| var dict: [K:V] = [:] | |
| for element in self { | |
| dict[keySelector(element)] = valueTransform(element) | |
| } |
One of the best ways to investigate a problematic Xamarin.Android Binding is to first ensure you have the proper tooling available:
A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.
Both UITableView and UICollectionView offer a similar API to register custom cell classes:
public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)| NS_ASSUME_NONNULL_BEGIN | |
| void Log(NSString *foo) { | |
| NSLog(@"%@", foo); | |
| } | |
| int main(int argc, const char * argv[]) { | |
| @autoreleasepool { | |
| NSDictionary *stuff = @{ | |
| @"a": @"Test" |
| # This script is to work round the problem of broken RubyMine dependencies for bundle files. | |
| # It uses an undocumented feature for RubyMine (but available in Intellij Idea) to create a | |
| # gems library xml file and update the iml file. | |
| # | |
| # See Rubymine issues: | |
| # https://youtrack.jetbrains.com/issue/RUBY-16428 | |
| # https://youtrack.jetbrains.com/issue/RUBY-15026 | |
| # https://youtrack.jetbrains.com/issue/RUBY-14542 | |
| # | |
| # Usage: |