Skip to content

Instantly share code, notes, and snippets.

View damodarnamala's full-sized avatar

Damodar damodarnamala

  • Hyderabad
View GitHub Profile
@damodarnamala
damodarnamala / Keychain.swift
Created September 16, 2022 03:37 — forked from s-aska/Keychain.swift
Swift Keychain class ( supported Xcode 6.0.1 )
import UIKit
import Security
class Keychain {
class func save(key: String, data: NSData) -> Bool {
let query = [
kSecClass as String : kSecClassGenericPassword as String,
kSecAttrAccount as String : key,
kSecValueData as String : data ]
@damodarnamala
damodarnamala / Scanner.swift
Created September 16, 2022 03:38 — forked from s-aska/Scanner.swift
Scanner
//
// DataScanner.swift
// DataScanner
//
// Created by Shinichiro Aska on 8/20/15.
// Copyright © 2015 Shinichiro Aska. All rights reserved.
//
import Foundation
@damodarnamala
damodarnamala / PreviewProviderModifier.swift
Created September 16, 2022 03:39 — forked from davidsteppenbeck/PreviewProviderModifier.swift
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
@damodarnamala
damodarnamala / Client.swift
Created September 16, 2022 03:41 — forked from kean/Client.swift
API Client (Archived)
// The MIT License (MIT)
//
// Copyright (c) 2017 Alexander Grebenyuk (github.com/kean).
import Foundation
import Alamofire
import RxSwift
import RxCocoa
// This post is **archived**. For a modern version that uses Async/Await and Actors, see the new article
@damodarnamala
damodarnamala / StickyLayout.swift
Created September 16, 2022 03:41 — forked from ilyapuchka/StickyLayout.swift
Really sticky collection view layout
// The issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin
// first header and last footer when bouncing. This layout subclass fixes that.
class StickyLayout: UICollectionViewFlowLayout {
override init() {
super.init()
self.sectionFootersPinToVisibleBounds = true
self.sectionHeadersPinToVisibleBounds = true
}
import SwiftUI
import PlaygroundSupport
// constants
let cardWidth: CGFloat = 343
let cardHeight: CGFloat = 212
let spacing = 36
let animation = Animation.spring()
let cardColors = [
Color(UIColor.systemRed),
@damodarnamala
damodarnamala / CombineFetcher.swift
Created September 16, 2022 03:47 — forked from stinger/CombineFetcher.swift
Combine - fetching data using URLSession publishers
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
@damodarnamala
damodarnamala / cross-view-lines.swift
Created September 16, 2022 03:47 — forked from bjhomer/cross-view-lines.swift
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI
@damodarnamala
damodarnamala / Delegate.swift
Created September 16, 2022 03:49 — forked from onevcat/Delegate.swift
An auto-weak delegate for handle modern delegate pattern.
import Foundation
/// A class that keeps a weakly reference for `self` when implementing `onXXX` behaviors.
/// Instead of remembering to keep `self` as weak in a stored closure:
///
/// ```swift
/// // MyClass.swift
/// var onDone: (() -> Void)?
/// func done() {
/// onDone?()
@damodarnamala
damodarnamala / TrimVideo.swift
Created September 16, 2022 03:50 — forked from acj/TrimVideo.swift
Trim video using AVFoundation in Swift
//
// TrimVideo.swift
// VideoLab
//
// Created by Adam Jensen on 3/28/15.
// Updated for Swift 5 (tested with Xcode 10.3) on 7/30/19.
// MIT license
//
import AVFoundation