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 UIKit | |
@main | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
func makeRefreshControl() -> UIRefreshControl { | |
let refresh = UIRefreshControl() |
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 | |
final class BracketScanner { | |
let text: String | |
init(text: String) { | |
self.text = text.trimmingCharacters(in: CharacterSet(charactersIn: "()")) | |
} | |
lazy var scanner: Scanner = { |
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 | |
@main | |
struct ToDoApp: App { | |
@StateObject var model: Model = .init() | |
var body: some Scene { | |
WindowGroup { | |
ScrollView { | |
VStack(alignment: .leading) { |
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
// Output of print(_viewDebugData), formatted for easier viewing | |
[SwiftUI._ViewDebug.Data( | |
data: [ | |
SwiftUI._ViewDebug.Property.value: SwiftUI._SafeAreaInsetsModifier(elements: [], nextInsets: nil), | |
SwiftUI._ViewDebug.Property.displayList: (display-list | |
(item #:identity 2 #:version 6 | |
(frame (143.66666666666666 354.0; 88.0 20.333333333333332)) | |
(text "Hello World" #:size (88.0, 20.333333333333332)) | |
) |
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
enum Cats { | |
private struct CatResponse: Decodable { | |
let url: URL | |
} | |
@discardableResult | |
static func getRandomImageURL(completion: @escaping (URL?) -> Void) -> URLSessionDataTask { | |
let request = URLRequest(url: URL(string: "https://api.thecatapi.com/v1/images/search")!) | |
let task = URLSession.shared.dataTask(with: request) { data, _, _ in | |
let catURL: URL? = { |
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
// reloadDataを使わないようにしましょう | |
import UIKit | |
import DiffableDataSources // https://github.com/ra1028/DiffableDataSources | |
@available(iOS, introduced: 13.0) | |
typealias TableViewDiffableDataSource = UITableViewDiffableDataSource | |
@available(iOS, introduced: 13.0) | |
typealias DiffableDataSourceSnapshot = NSDiffableDataSourceSnapshot | |
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 UIKit | |
enum Weekday: Int { | |
case monday = 1 | |
case tuesday = 2 | |
case wednesday = 3 | |
case thursday = 4 | |
case friday = 5 | |
case saturday = 6 | |
case sunday = 0 |
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
def bit_is_set(byteval,idx): | |
return ((byteval&(1<<idx))!=0) | |
def read_int_bbo(f, s, signed=False): | |
return int.from_bytes(f.read(s), byteorder='big', signed=signed) | |
def decompressECD(f, out_fname): #file handle at ECD start position, out file name | |
magic = f.read(3) | |
if not magic == b'ECD': | |
return |
NewerOlder