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
| struct MultipartRequest { | |
| private let boundary = UUID().uuidString | |
| private var bodyString: String = "" | |
| private var body = Data() | |
| var request: URLRequest | |
| init( | |
| url: URL, |
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
| typealias SortDescriptor<Value> = (Value, Value) -> Bool | |
| protocol Sortable: class { | |
| var sortRules: [SortRule] { get } | |
| var currentRule: SortRule { get } | |
| func sortData() | |
| } | |
| extension Sortable { |
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
| from itertools import groupby | |
| def encode(text): | |
| """ | |
| Returns the run-length encoded version of the text | |
| (numbers after symbols, length = 1 is skipped) | |
| """ | |
| splitted = list(text) | |
| grouped = [list(j) for i, j in groupby(splitted)] |
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 re | |
| def decode(text): | |
| """ | |
| Decodes the text using run-length encoding | |
| """ | |
| return re.sub(r'(\D)(\d*)', lambda m: m.group(1) * int(m.group(2)) if m.group(2) != '' else m.group(1), text) |
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 | |
| struct CustomVStack<Content: View>: View { | |
| let content: () -> Content | |
| init(@ViewBuilder content: @escaping () -> Content) { | |
| self.content = content | |
| } | |
| var body: some View { | |
| VStack(spacing: 0) { |
OlderNewer