Skip to content

Instantly share code, notes, and snippets.

Avatar

Praveen Kumar pvn

  • Bangalore, India
View GitHub Profile
@pvn
pvn / PKDataManager.swift
Created Sep 26, 2018
Helper methods for storing data in UserDefaults using PKDataManager class
View PKDataManager.swift
class PKDataManager {
static let defaults = UserDefaults.standard
// check if 'key' is present in user defaults
static func isKeyPresentInUserDefaults(key: String) -> Bool {
return defaults.object(forKey: key) != nil
}
// store the SETs as string for given 'key' in user defaults
@pvn
pvn / ColorExtension.swift
Created Sep 16, 2018
Color extension using swift
View ColorExtension.swift
import Foundation
import UIKit
extension UIColor {
convenience init(hexString: String, alpha: CGFloat = 1.0) {
let hexString: String = hexString.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
let scanner = Scanner(string: hexString)
if (hexString.hasPrefix("#")) {
scanner.scanLocation = 1
@pvn
pvn / StringExtension.swift
Last active Sep 27, 2018
String extension using swift
View StringExtension.swift
extension String
{
var length: Int {
get {
return self.count
}
}
var startToEndRange: Range<String.Index> {
get {
let start = self.index(self.startIndex, offsetBy: 0)
@pvn
pvn / ArrayExtension.swift
Last active Sep 15, 2018
Swift: Array Extension
View ArrayExtension.swift
/* Compare two array has the same value */
// firstArray = ['A', 'B', 'C', 'A']
// secondArray = ['A', 'B', 'C', 'A']
// firstArray.isDuplicateOf(secondArray)
extension Array where Element: Comparable {
func isDuplicateOf(as other: [Element]) -> Bool {
return self.count == other.count && self.sorted() == other.sorted()
}
@pvn
pvn / linked_list.py
Last active Aug 30, 2020
Linked list implementation with add, search, delete, output operation
View linked_list.py
class Node:
def __init__(self, data):
self.data = data
self.next = None
return
def has_value(self, value):
You can’t perform that action at this time.