Skip to content

Instantly share code, notes, and snippets.

View prat14k's full-sized avatar
🏠
Working from home

Prateek Sharma prat14k

🏠
Working from home
View GitHub Profile
@prat14k
prat14k / Log.swift
Created September 15, 2021 06:57 — forked from aryamansharda/Log.swift
Logging In Swift [The Right Way]
import Foundation
enum Log {
enum LogLevel {
case info
case warning
case error
fileprivate var prefix: String {
switch self {
@prat14k
prat14k / MD5StringTest.swift
Created March 19, 2019 09:26 — forked from khanlou/MD5StringTest.swift
MD5 and SHA1 on String in Swift 3
import XCTest
@testable import <#project#>
class StringMD5Test: XCTestCase {
func testMD5() {
let string = "soroush khanlou"
XCTAssertEqual(string.md5, "954d741d14b14002d1ba88f600eee635")
import Foundation
extension CALayer {
public func animate() -> CALayerAnimate {
return CALayerAnimate(layer: self)
}
}
public class CALayerAnimate {
@prat14k
prat14k / CustomAlignedButton.swift
Last active July 27, 2018 11:02 — forked from harmittaa/ButtonWithImage.swift
UIButton with label and right aligned image(adjacent to the border)
import UIKit
class ButtonWithImage: UIButton {
override func layoutSubviews() {
super.layoutSubviews()
if imageView != nil {
imageEdgeInsets = UIEdgeInsets(top: 5, left: (bounds.width - 35), bottom: 5, right: 5)
titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: (imageView?.frame.width)!)
}
@prat14k
prat14k / manual-uninstall-paragon-ntfs.sh
Created July 26, 2018 07:48 — forked from guycalledseven/manual-uninstall-paragon-ntfs.sh
Manually remove Paragon NTFS v15 leftovers MacOS
# after appcleaner does his magic, do this
sudo rm -rf "/Library/Application Support/Paragon Software/"
sudo rm /Library/LaunchDaemons/com.paragon-software.installer.plist
sudo rm /Library/LaunchDaemons/com.paragon-software.ntfs.loader.plist
sudo rm /Library/LaunchDaemons/com.paragon-software.ntfsd.plist
sudo rm /Library/LaunchAgents/com.paragon-software.ntfs.notification-agent.plist
sudo rm -rf /Library/Filesystems/ufsd_NTFS.fs/
sudo rm -rf /Library/PrivilegedHelperTools/com.paragon-software.installer
sudo rm -rf /Library/Extensions/ufsd_NTFS.kext/
@prat14k
prat14k / remove_tuxera.sh
Created July 26, 2018 07:45 — forked from miguelmota/remove_tuxera.sh
Completely uninstall and remove Tuxera NTFS on MacOs (resets trial version)
rm -rf /Applications/Tuxera\ Disk\ Manager.app
rm -rf /Library/Application\ Support/Tuxera\ NTFS
rm -rf /Library/Filesystems/fusefs_txantfs.fs
@prat14k
prat14k / morphing.swift
Last active July 27, 2018 11:08 — forked from AliSoftware/morphing.swift
A simple demo of doing some morphing using CAShapeLayer & UIBezierPath. Animation done using CABasicAnimation.
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
func addLabel() {
let label = UILabel()
label.frame = CGRect(x: 150, y: 200, width: 200, height: 20)
label.text = "Hello World!"
label.textColor = .black
@prat14k
prat14k / WiFiSsid.swift
Created July 18, 2018 06:15 — forked from werediver/WiFiSsid.swift
Get the connected Wi-Fi network SSID on iOS (in Swift).
import Foundation
import SystemConfiguration.CaptiveNetwork
func getWiFiSsid() -> String? {
var ssid: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
@prat14k
prat14k / P12toPEM.txt
Created June 28, 2018 09:53 — forked from shahdhiren/P12toPEM.txt
Convert P12 file for Push Notification to PEM format
Development Phase:
Step 1: Create Certificate .pem from Certificate .p12
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12
Step 2: Create Key .pem from Key .p12
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12
Step 3: Optional (If you want to remove pass phrase asked in second step)
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem
@prat14k
prat14k / remove-bottom-line-navbar.md
Created June 22, 2018 07:56 — forked from vinhnx/remove-bottom-line-navbar.md
remove 1px bottom line of the navigation bar

If you just want to use a solid navigation bar color and have set this up in your storyboard, use this code in your AppDelegate class to remove the 1 pixel border via the appearance proxy:

Objective-C

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
                                  forBarPosition:UIBarPositionAny
                                      barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];