Skip to content

Instantly share code, notes, and snippets.

View JayachandraA's full-sized avatar
🎯
Focusing

Jayachandra Agraharam JayachandraA

🎯
Focusing
View GitHub Profile
import Foundation
import PlaygroundSupport
/// A thread-safe array.
public class SynchronizedArray<Element> {
private let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent)
private var array = [Element]()
public init() { }
@JayachandraA
JayachandraA / country_names_codes
Created September 15, 2022 15:02
A json file of countries and their calling code
{
"status": "OK",
"code": 200,
"message": {
"countryList": [
{
"code": "AD",
"name": "Andorra",
"calling_code": "+376"
},
@JayachandraA
JayachandraA / ZigZagCardView.swift
Last active October 17, 2019 11:13
Swift: Core Graphics custom drawing
class ZigZagCardView: UIView {
override func awakeFromNib() {
layer.cornerRadius = 5
layer.masksToBounds = true
backgroundColor = UIColor.clear
}
override func draw(_ rect: CGRect) {
super.draw(rect)
@JayachandraA
JayachandraA / Steps_to_create_python_project.txt
Created September 18, 2019 06:56
Steps to create python project
Steps to create new python project with Django
STEP 1: Open terminal and go to root directory where you want to create a project
STEP 2: Enable virtual environment (i.e, $virtualenv venv -> $source venv/bin/activate)
STEP 3: Install Django package/framework (i.e, $ pip install Django), this includes the command django-admin as swell
STEP 4: Now, create new project i.e, $django-admin startproject <project_name>
STEP 5: Verify your created project by $ python manage.py runserver
STEP 6: Now, create new app i.e, $python manage.py startapp <app_name>
@JayachandraA
JayachandraA / Activate Office 2019 for macOS VoL.md
Created August 30, 2019 06:27 — forked from zthxxx/Activate Office 2019 for macOS VoL.md
crack activate office on mac with license file

Activate MS Office 2019/2016 for macOS - Microsoft_Office_2019_VL_Serializer

Office 2019 above

2019-06-03

Note that Office2019 DO NOT support activate via simple copy/paste plist license file which is the simplest way to activate Office 2016. Fortunately, you can also use the VL Serializer tool, just install Office 2019 and Serializer, then run Serializer to activate.

Ref

protocol Reusable {
static var reuseIdentifier: String {get}
}
extension Reusable {
static var reuseIdentifier: String {
return String(describing: self)
}
}
@JayachandraA
JayachandraA / reading_local_json_file.swift
Created December 28, 2018 10:47
Sample code snippet to read local JSON file in iOS10 and iOS 11
if let resource = Bundle.main.url(forResource: "US zip (postal) codes", withExtension: "json"),
let postalCodesData = try? Data(contentsOf: resource, options: Data.ReadingOptions.alwaysMapped){
do{
let decodedObject = try JSONDecoder().decode(PostalCodeResponse.self, from: postalCodesData)
DispatchQueue.main.async { [weak self] in
// update UI
}
}catch let parsingError {
print(parsingError)
@JayachandraA
JayachandraA / user_local_notifications.swift
Created December 27, 2018 10:55
The following snippet of code provides how to display a locations to the user. In order to display the notification first of all you are required to request the user permissions to send your local notification.
// request for user permisstions
UNUserNotificationCenter.current().requestAuthorization(options: [UNAuthorizationOptions.badge, UNAuthorizationOptions.sound, UNAuthorizationOptions.alert]) { (yes, error) in
}
// fill up with the following objects
let context = UNMutableNotificationContent()
context.badge = NSNumber(integerLiteral: UIApplication.shared.applicationIconBadgeNumber + 1)
context.title = "It is Gym time now"
context.body = "Now you have to wake up and go to Gym."
@JayachandraA
JayachandraA / gradient_layer_with_angle_in_swift.swift
Created December 27, 2018 10:04
gradient layer with angle in swift
// how to create a gradient view
let gradientLayer = CAGradientLayer()
gradientLayer.frame = view.bounds
gradientLayer.colors = [UIColor.orange.cgColor, UIColor.white.cgColor,UIColor.green.cgColor]
gradientLayer.locations = [0.0, 0.5, 1.0]
gradientLayer.apply(angle: 45.0)
view.layer.insertSublayer(gradientLayer, at: 0)
//helper extention to CAGradientLayer
extension UITextField {
// OPTION - 1
struct Instance {
static var floating: Bool = false
}
var floating: Bool{