Skip to content

Instantly share code, notes, and snippets.

View damodarnamala's full-sized avatar

Damodar damodarnamala

  • Hyderabad
View GitHub Profile
@sanjayhub
sanjayhub / DispatchInMainQueueTests.swift
Last active October 7, 2022 11:30
UnitTesting Asynchronous code
//
// DispatchInMainQueueTests.swift
// DispatchInMainQueueTests
//
// Created by Kumar, Sanjay (623) on 29/09/22.
//
import XCTest
@testable import DispatchInMainQueue
@bjhomer
bjhomer / cross-view-lines.swift
Last active November 5, 2022 05:31
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: a honeycomb eager grid
// blog article: https://swiftui-lab.com/eager-grids
import SwiftUI
struct Person {
let name: String
let image: String
var color: Color = .accentColor
//
// ContentView.swift
// Shared
//
// Created by Chris Eidhof on 05.05.22.
//
import SwiftUI
struct ContentView: View {
//
// ContentView.swift
// Shared
//
// Created by Chris Eidhof on 16.04.22.
//
import SwiftUI
struct Jump: AnimatableModifier {
extension Result {
public func `catch`(_ handler: () throws -> Success) -> Result<Success, Error> {
flatMapError { _ in
.init { try handler() }
}
}
public func `catch`(_ handler: (Failure) throws -> Success) -> Result<Success, Error> {
flatMapError { error in
.init { try handler(error) }
import XCTest
struct Scenario: ScenarioGivenContinuation, ScenarioWhenContinuation {
init(_ description: String) {
print("Scenario: \(description)")
}
struct Given: ScenarioWhenContinuation {
fileprivate init(description: String, setup: () throws -> Void) rethrows {
@V8tr
V8tr / AutoLayoutDSL.swift
Last active October 31, 2023 17:42
Auto Layout DSL
import UIKit
/// Represents a single `NSLayoutConstraint`
enum LayoutAnchor {
case constant(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
constant: CGFloat)
case relative(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
extension TimeInterval {
var milliseconds: Int {
return Int((truncatingRemainder(dividingBy: 1)) * 1000)
}
var seconds: Int {
return Int(self) % 60
}
var minutes: Int {
@davidsteppenbeck
davidsteppenbeck / PreviewProviderModifier.swift
Last active October 31, 2022 10:30
A SwiftUI view modifier for simple preview providers.
import SwiftUI
enum PreviewProviderMode: CaseIterable {
/// Use for a light appearance preview.
case lightMode
/// Use for a dark appearance preview.
case darkMode