This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Http\Controllers; | |
| use Illuminate\Foundation\Bus\DispatchesJobs; | |
| use Illuminate\Routing\Controller as BaseController; | |
| use Illuminate\Foundation\Validation\ValidatesRequests; | |
| use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | |
| use Illuminate\Validation\Validator; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| extension UIViewController { | |
| func openFacebook(pageId: String, pageName: String) { | |
| guard let facebookURL = URL(string: "fb://page/?id=\(pageId)") else { | |
| return | |
| } | |
| if (UIApplication.shared.canOpenURL(facebookURL)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #laravel | |
| alias pa="php artisan" | |
| #git | |
| alias gi="git init" | |
| alias gs="git status" | |
| alias ga="git add" | |
| alias gc="git commit -m" | |
| alias gac="git add .;git commit -m" | |
| alias gp="git push" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import CoreTelephony | |
| struct PhoneHelper { | |
| static func getCountryCode() -> String { | |
| guard let carrier = CTTelephonyNetworkInfo().subscriberCellularProvider, let countryCode = carrier.isoCountryCode else { return "+" } | |
| let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // CustomUserDefaults.swift - Less | |
| import Foundation | |
| class CustomUserDefaults { | |
| // define all keys needed | |
| enum DefaultsKey: String, CaseIterable { | |
| case name | |
| case email | |
| case isUserLogin | |
| case userLevel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // save name and email | |
| let fullName = "John Smith" | |
| CustomUserDefaults.shared.set(fullName, key: .name) | |
| let userEmail = "[email protected]" | |
| CustomUserDefaults.shared.set(userEmail, key: .email) | |
| // print stored name and email | |
| let savedName = CustomUserDefaults.shared.get(key: .name) | |
| print(savedName) // result: Optional(John Smith) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if let savedName = CustomUserDefaults.shared.get(key: .name) as? String { | |
| print(savedName) // result: [email protected] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // CustomUserDefaults.swift (full) | |
| import Foundation | |
| class CustomUserDefaults { | |
| // define all keys needed | |
| enum DefaultsKey: String, CaseIterable { | |
| case name | |
| case email | |
| case isUserLogin | |
| case userLevel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import SwiftUI | |
| extension UIViewController { | |
| // enable preview for UIKit | |
| // source: https://fluffy.es/xcode-previews-uikit/ | |
| @available(iOS 13, *) | |
| private struct Preview: UIViewControllerRepresentable { | |
| // this variable is used for injecting the current view controller | |
| let viewController: UIViewController |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import SwiftUI | |
| extension UIView { | |
| // enable preview for UIKit | |
| // source: https://dev.to/gualtierofr/preview-uikit-views-in-xcode-3543 | |
| @available(iOS 13, *) | |
| private struct Preview: UIViewRepresentable { | |
| typealias UIViewType = UIView | |
| let view: UIView |
OlderNewer