Skip to content

Instantly share code, notes, and snippets.

View rafattouqir's full-sized avatar

MD Rafat Touqir rafattouqir

View GitHub Profile
//call the method
let convertedDateString = self.dateFromString("2019-05-20", fromFormat: "yyyy-MM-dd", toFormat: "dd-MM-yyyy")
print(convertedDateString ?? "Failed to convert date")
func dateFromString(_ dateString:String, fromFormat:String, toFormat: String) -> String? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = fromFormat
@rafattouqir
rafattouqir / tab.bash
Created July 21, 2019 17:00 — forked from bobthecow/tab.bash
Open new Terminal tabs from the command line
#!/bin/bash
#
# Open new Terminal tabs from the command line
#
# Author: Justin Hileman (http://justinhileman.com)
#
# Installation:
# Add the following function to your `.bashrc` or `.bash_profile`,
# or save it somewhere (e.g. `~/.tab.bash`) and source it in `.bashrc`
#
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell: CustomCollectionViewCell = collectionView.dequeueReusableCell(forIndexPath: indexPath)
...
//add shadow
cell.applyShadow()
....
return cell
}
import UIKit
// MARK: - SafeArea Extensions
extension UIView {
var safeTopAnchor: NSLayoutYAxisAnchor {
if #available(iOS 11.0, *) {
return self.safeAreaLayoutGuide.topAnchor
}
return self.topAnchor
protocol LoaderViewType: UIView {
func startAnimating()
func stopAnimating()
}
class LoaderButton: UIButton, LoaderViewType {
fileprivate let activityLoader: UIActivityIndicatorView = {
let indicator = UIActivityIndicatorView(style: .gray)
indicator.translatesAutoresizingMaskIntoConstraints = false
@rafattouqir
rafattouqir / ThrottledSearchController.swift
Created February 2, 2020 12:19
Simple RxSwift like Throttle functionality added to UISearchBar and UISearchController
// ThrottledSearchController.swift
// Created by Daniele Margutti on 10/19/2017
// Updated by RAFAT TOUQIR RAFSUN.
import UIKit
class ThrottledSearchController: UISearchController{
// Mark this property as lazy to defer initialization until
// the searchBar property is called.
private lazy var customSearchBar = ThrottledSearchBar()