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 JSONManager { | |
| struct DecodeReturn<T: Decodable> { | |
| var value: T | |
| var error: (any Error)? | |
| } | |
| static func encodeJSON<T: Encodable>(_ data: T) throws -> Data? { |
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
| // A URLSession extension that fetches data from a URL and decodes to some Decodable type. | |
| // Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL) | |
| // Note: this requires Swift 5.5. | |
| extension URLSession { | |
| func decode<T: Decodable>( | |
| _ type: T.Type = T.self, | |
| from url: URL, | |
| keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, | |
| dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData, | |
| dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate |
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 | |
| enum PreviewProviderMode: CaseIterable { | |
| /// Use for a light appearance preview. | |
| case lightMode | |
| /// Use for a dark appearance preview. | |
| case darkMode | |
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
| # A Best in Class Checklist | |
| A boiled down checklist adapted from this [post](https://www.swiftjectivec.com/a-best-in-class-app/), created by @jordanmorgan10. | |
| > To use this, create a Github Issue in your own repo, and simply copy and paste this text. | |
| ## iOS Core Technology | |
| _Things any iOS app can benefit from_ | |
| - [ ] iCloud Sync | |
| - [ ] Focus Filter Support |
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
| // Run any SwiftUI view as a Mac app. | |
| import Cocoa | |
| import SwiftUI | |
| NSApplication.shared.run { | |
| VStack { | |
| Text("Hello, World") | |
| .padding() | |
| .background(Capsule().fill(Color.blue)) |
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
| // Created by Marcin Krzyzanowski | |
| import Foundation | |
| public protocol JSONEncodable: Encodable { } | |
| public extension JSONEncodable { | |
| func toJSON(using encoder: @autoclosure () -> JSONEncoder = JSONEncoder()) throws -> String { | |
| try String(decoding: encoder().encode(self), as: UTF8.self) | |
| } |
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
| const Twit = require('twit') | |
| const { Observable, Subject, interval, merge, of, from, race } = require('rxjs') | |
| const { map, flatMap, distinct, zip, tap, filter, bufferTime, count } = require('rxjs/operators') | |
| const config = require('./config') | |
| /* | |
| * config should be an object like this | |
| * { | |
| * targetUsername: string | |
| * minFollowerCount: number |
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 | |
| let dateFormatter = DateFormatter() | |
| struct NoteItem: Codable, Hashable, Identifiable { | |
| let id: Int | |
| let text: String | |
| var date = Date() | |
| var dateText: String { | |
| dateFormatter.dateFormat = "MMM d yyyy, h:mm a" |
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
| #!/usr/bin/env python3 | |
| from collections import Counter | |
| from itertools import islice | |
| import re | |
| import string | |
| import sys | |
| MIN_PHRASE_LENGTH = 2 |
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
| [ | |
| { | |
| "name": "Aboleth", | |
| "meta": "Large aberration, lawful evil", | |
| "Armor Class": "17 (Natural Armor)", | |
| "Hit Points": "135 (18d10 + 36)", | |
| "Speed": "10 ft., swim 40 ft. ", | |
| "STR": "21", | |
| "STR_mod": "(+5)", | |
| "DEX": "9", |
NewerOlder