Skip to content

Instantly share code, notes, and snippets.

View AlexandrGraschenkov's full-sized avatar

Alexandr Graschenkov AlexandrGraschenkov

View GitHub Profile
import Darwin
class FileLineReader {
init?(path: String, removeNewLineOnEnd: Bool = true) {
file = fopen(path, "r")
self.removeNewLineOnEnd = removeNewLineOnEnd
if file == nil {
return nil
}
}
@AlexandrGraschenkov
AlexandrGraschenkov / DispatchQueue+Ex.swift
Created May 21, 2021 09:25
Helpers for easy control on witch queue run your code
extension DispatchQueue {
static var background: DispatchQueue { return DispatchQueue.global(qos: .background) }
}
public typealias Cancelable = ()->()
func performInMain(mode: CFRunLoopMode = CFRunLoopMode.commonModes, closure: @escaping ()->()) {
if Thread.isMainThread && mode == .commonModes {