Skip to content

Instantly share code, notes, and snippets.

View jeksys's full-sized avatar

Eugene Yagrushkin jeksys

View GitHub Profile
@jeksys
jeksys / Example.swift
Created July 8, 2021 05:25 — forked from VAnsimov/HostingView Example.swift
SwiftUI View to UIView
import UIKit
import SwiftUI
// SwiftUI
struct SomeView: View, HostingViewInitialization {
var body: some View {
Text("Hello World!")
}
}
import Foundation
extension CustomStringConvertible {
var description: String {
var description: String = "\(type(of: self))("
let selfMirror = Mirror(reflecting: self)
for child in selfMirror.children {
if let propertyName = child.label {
@jeksys
jeksys / NotificationTestCase.swift
Created May 30, 2019 16:53 — forked from fxm90/NotificationTestCase.swift
XCTest - Assert notification (not) triggered.
import XCTest
class NotificationTestCase: XCTestCase {
func testTriggerNotification() {
expectation(forNotification: .fooBar,
object: nil,
handler: nil)
let notificationCenter = NotificationCenter.default
import PlaygroundSupport
import Foundation
struct Resource<A> {
var request: URLRequest
var parse: (Data) throws -> A
}
protocol Loadable {
static var request: URLRequest { get }
@jeksys
jeksys / SimpleParsingJson.swift
Created February 28, 2019 17:17 — forked from kobeumut/SimpleParsingJson.swift
Simple Fetch Url and Parse Json on Swift 4 with codable and URLSession
func fetchResultsFromApi() {
struct MyGitHub: Codable {
let name: String?
let location: String?
let followers: Int?
let avatarUrl: URL?
let repos: Int?
private enum CodingKeys: String, CodingKey {
@jeksys
jeksys / Swift3Dates.swift
Last active November 15, 2016 22:29 — forked from stinger/Swift3Dates.swift
Swift 3: Working with dates
//: Playground - noun: a place where people can play
// playing with dates
import Foundation
let date = Date()
let myLocale = Locale(identifier: "en_CA")
//: ### Setting an application-wide `TimeZone`
//: Notice how we use if-let in case the abbreviation is wrong. It will fallback to the default timezone in that case.
@jeksys
jeksys / NSDateFormatter cheat sheet
Created March 12, 2016 04:05 — forked from romaonthego/NSDateFormatter cheat sheet
Date Formats for NSDateFormatter
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)