Skip to content

Instantly share code, notes, and snippets.

@udaypandey
udaypandey / RxSwiftOperators.swift
Last active September 8, 2018 11:59
Try out rxSwift operators
//
// ViewController.swift
// TryRx
//
// Created by Uday Pandey on 15/06/2018.
// Copyright © 2018 Thirstysea Ltd. All rights reserved.
//
import UIKit
import RxSwift
@udaypandey
udaypandey / URLSession+Shared.swift
Last active June 7, 2019 08:34
URLSession shared vs new instance
import Foundation
// Code snippet for testing URLSession shared vs new instances
// Salient Points:
//
// - Think of URLSession as a browser instead of a browser tab. If you create a new URLSession instance, you get a new browser and not a new tab.
// - But,
// - The shared instance uses a shared cookie storage instance.
// - If you create a new URLSession with a default configuration, it will still point to the same shared cookie storage.
// - In other words, anything you want to change, change, else they will by default point to some shared instances.
@udaypandey
udaypandey / GeometryPrinter.swift
Last active January 16, 2021 21:40
Debug print view for SwiftUI
// Helper view to debug various layout sizes. A print does not work in the body of the view.
//
// Usage
// Text("Hello world")
// .background(GeometryPrinter())
// Text("Hello world")
// .background(GeometryPrinter(prefix: "text"))
// Text("Hello world")
// .background(GeometryPrinter(prefix: "text", color: .green))
//
@udaypandey
udaypandey / ViewModel+Coordinator+Rx.swift
Created February 19, 2020 05:08
Coordinator with Rx + ViewModel
import UIKit
import RxCocoa
import RxSwift
protocol CoordinatorType {
associatedtype Event
func fsm(event: Event)
}
enum RegistrationEvent {
@udaypandey
udaypandey / json.swift
Last active October 19, 2021 11:15
Sample json
let json = """
{
"slides": [
{
"title": "SwiftUI In Depth",
"type": "swiftui"
},
{
"title": "Watch OS Overview",
"type": "watchos"
let first = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4, 5, 6, 7, 8, 9, 0]
let second = [4, 5, 6]
let first = "Hello World Hello World"
let second = "World"
@udaypandey
udaypandey / test_helpers.swift
Last active December 10, 2021 13:57
XCTest Helpers for Parsing JSON
import Foundation
public typealias UserIdentifier = String
struct User: Codable, Equatable {
let userId: UserIdentifier
let firstName: String
let lastName: String
let email: String
@udaypandey
udaypandey / xcode.openssl.log
Created February 11, 2022 11:23
Openssl Issue
dyld[10976]: Library not loaded: @rpath/openssl.framework/openssl
Referenced from: /private/var/containers/Bundle/Application/18542682-F42D-4D3B-A97E-C6DE7C019E93/Garrison.app/Frameworks/AppCoreWrapper.framework/AppCoreWrapper
Reason: tried: '/usr/lib/swift/openssl.framework/openssl' (no such file), '/private/var/containers/Bundle/Application/18542682-F42D-4D3B-A97E-C6DE7C019E93/Garrison.app/Frameworks/openssl.framework/openssl' (no such file), '/private/var/containers/Bundle/Application/18542682-F42D-4D3B-A97E-C6DE7C019E93/Garrison.app/Frameworks/AppCoreWrapper.framework/Frameworks/openssl.framework/openssl' (code signature in <4F288B6D-CF91-349E-B898-2D971560B5E2> '/private/var/containers/Bundle/Application/18542682-F42D-4D3B-A97E-C6DE7C019E93/Garrison.app/Frameworks/AppCoreWrapper.framework/Frameworks/openssl.framework/openssl' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/private/var/containers/Bundle/Application/18542682-F42
@udaypandey
udaypandey / message.swift
Last active November 23, 2022 13:43
Swift Callback to message conversion
//
// SampleDelegateWrapper.swift
// Plugin
//
// Created by Uday Pandey on 18/11/2022.
//
import Foundation
enum ZigbeePeripheral {}