Skip to content

Instantly share code, notes, and snippets.

View satishbabariya's full-sized avatar

Satish Babariya satishbabariya

View GitHub Profile
@satishbabariya
satishbabariya / objc2swift.command
Created November 22, 2017 11:03
Convert Objective C files to Swift in whole Project
#!/bin/bash
cd "$(dirname "$0")"
files=($(find . -type f -regex "^.*m"))
for item in ${files[*]}
do
objc2swift $item
done
// MARK: - Server Request -
internal func userDetailsRequest() {
if reachability.connection != .none {
operationQueue.addOperation { [weak self] in
if self == nil {
return
}
self!.isRunningRequest = true
@satishbabariya
satishbabariya / StatusBarColor.swift
Created March 2, 2018 09:28
Change status bar color
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = CustomNavigationController(rootViewController: TabsController())
window?.makeKeyAndVisible()
//Change status bar color
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
@satishbabariya
satishbabariya / HighlightWarnings.command
Created March 12, 2018 06:42
Highlight Warnings TODO:|FIXME:|WARNING:
TAGS="TODO:|FIXME:|WARNING:"
ERRORTAG="ERROR:"
find "$PROJECT_DIR/$PROJECT_NAME" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"| perl -p -e "s/($ERRORTAG)/ error: \$1/"
set -x
#--------- START OF CONFIGURATION
# Get base path to project
BASE_PATH="$PROJECT_DIR/$PROJECT_NAME"
# Get path to Laurine Generator script
LAURINE_PATH="$BASE_PATH/LocalizationsGenerator.swift"
import Foundation
// A Naïve Event Implementation
// class Event<T> {
//
// typealias EventHandler = T -> ()
//
// private var eventHandlers = [EventHandler]()
//
@satishbabariya
satishbabariya / cURL.swift
Created July 2, 2018 12:04
URLRequest To cURL
extension URLRequest {
/**
Returns a cURL command representation of this URL request.
*/
public var curlString: String {
guard let url = url else { return "" }
var baseCommand = "curl \(url.absoluteString)"
if httpMethod == "HEAD" {
import RxSwift
import Foundation
import Reachability
public enum ReachabilityStatus {
case reachable(viaWiFi: Bool)
case unreachable
}
extension ReachabilityStatus {
import Foundation
import RxSwift
import RxCocoa
private struct ActivityToken<E> : ObservableConvertibleType, Disposable {
private let _source: Observable<E>
private let _dispose: Cancelable
init(source: Observable<E>, disposeAction: @escaping () -> ()) {
_source = source
struct Application {
struct Auth {
static func isUserLoggedin() -> Bool {
return Defaults[.authToken] != ""
}
static func signOut() {
Defaults.removeAll()
Application.appDelegate()?.isAuthorized()
}