Skip to content

Instantly share code, notes, and snippets.

View janeshsutharios's full-sized avatar

Janesh suthar janeshsutharios

View GitHub Profile
@janeshsutharios
janeshsutharios / swift6Concurrency.swift
Created August 1, 2025 15:40
Adding swift 6 concurrency with packages
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Common",
platforms: [
.iOS(.v15),
],
import SwiftUI
// MARK: - Model
struct UserModel: Identifiable, Decodable {
let id: Int
let name: String
}
// WastingTimeOnStackOverflowTests.swift Created by mason on 2016-09-18.
import XCTest
/// Measures performance of two different ways of checking whether an index is valid
/// for a given array (the variable "a" is an array of 1,000,000 unique strings, and
/// "val" is the index to be checked):
///
/// a.indices.contains(val)
/// vs:
@janeshsutharios
janeshsutharios / EncryptionHelper.swift
Created December 3, 2021 05:17
Encryption in iOS
//
// EncryptionHelper.swift
// Demo3
//
//
import Foundation
import CommonCrypto
struct AES {
@janeshsutharios
janeshsutharios / PaddingUILabel.swift
Created April 10, 2021 05:59
PaddingUILabel.swift
class PaddingLabel: UILabel {
@IBInspectable var topInset: CGFloat = 5.0
@IBInspectable var bottomInset: CGFloat = 5.0
@IBInspectable var leftInset: CGFloat = 7.0
@IBInspectable var rightInset: CGFloat = 7.0
override func drawText(in rect: CGRect) {
let insets = UIEdgeInsets(top: topInset, left: leftInset, bottom: bottomInset, right: rightInset)
super.drawText(in: rect.inset(by: insets))
@janeshsutharios
janeshsutharios / PaddingUItextField.swift
Created April 10, 2021 05:59
PaddingUItextField.swift
class PaddingTextField: UITextField {
let padding = UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
override open func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: padding)
}
override open func placeholderRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: padding)
let imageCache = NSCache<NSString, UIImage>()
extension UIImageView {
func loadImageUsingCache(withUrl urlString : String) {
let url = URL(string: urlString)
if url == nil {return}
self.image = nil
if let cachedImage = imageCache.object(forKey: urlString as NSString) {
self.image = cachedImage
return
}
@janeshsutharios
janeshsutharios / ClouserDataBinding.swift
Last active July 15, 2019 07:01
Data Binding through Clousers
//Step 1:
//Create button clouser
var tapsOnButtonClouser:() -> () = {}
var isTempBool = false
//Step 2: Setup that function
func setUpClouser() {
tapsOnButtonClouser = { [weak self] in
guard let localSelf = self else {return}
localSelf.isTempBool = !localSelf.isTempBool
print("Temp Bool changed to--> ",localSelf.isTempBool)
@janeshsutharios
janeshsutharios / InternetTime
Created March 27, 2019 10:40
Get time from internet
import UIKit
extension Formatter {
static let enUSPOSIX: DateFormatter = {
let formatter = DateFormatter()
@janeshsutharios
janeshsutharios / Obfuscator.swift
Created February 21, 2019 11:59 — forked from DejanEnspyra/Obfuscator.swift
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {