Skip to content

Instantly share code, notes, and snippets.

View StanDimitroff's full-sized avatar
🔨

Stanislav Dimitrov StanDimitroff

🔨
View GitHub Profile
struct MultipartRequest {
private let boundary = UUID().uuidString
private var bodyString: String = ""
private var body = Data()
var request: URLRequest
init(
url: URL,
typealias SortDescriptor<Value> = (Value, Value) -> Bool
protocol Sortable: class {
var sortRules: [SortRule] { get }
var currentRule: SortRule { get }
func sortData()
}
extension Sortable {
@StanDimitroff
StanDimitroff / run_lenght_encoding.py
Last active May 7, 2018 07:17
Run-length encoding implementation in Python
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)]
@StanDimitroff
StanDimitroff / run_lenght_decoding.py
Created May 7, 2018 12:22
Run-length decoding implementation in python
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)
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) {