Skip to content

Instantly share code, notes, and snippets.

View quocnb's full-sized avatar
♟️

Quoc Nguyen quocnb

♟️
View GitHub Profile
@quocnb
quocnb / UserNotificationsExample.swift
Last active March 16, 2022 12:28
UserNotifications iOS 10 Example
import UserNotifications
// 1. Request Permission
func requestAuthorization() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { (granted, error) in
if granted {
// Success
} else {
// Error
print(error?.localizedDescription)
@quocnb
quocnb / XibLocalized.swift
Created October 31, 2017 23:50
#iOS#Swift Localized String For Xib File
public protocol Localizable {
func localize()
}
public extension Localizable {
public func localize(_ string: String?) -> String? {
guard let term = string, term.hasPrefix("@") else {
return string
}

Tools:

*** Install Xcode first for save the time *** Homebrew need xcode command line tools first

Homebrew

https://brew.sh/

Gitcomplete

Install Git and bash-completion:

brew install git && brew install bash-completion

Code quality control

Swiftlint is best choice

Bug control

Install Crashlytics

Upload dsym file (using fastlane for auto do it)

Auto build

Fastlane is best choice.

Setup

1. Install Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Add Homebrew Tap

brew tap vapor/homebrew-tap
brew update

NaN Percent

total = df.isnull().sum().sort_values(ascending=False)
percent = (df.isnull().sum()/df.isnull().count()).sort_values(ascending=False)
missing_data = pd.concat([total, percent], axis=1, keys=['Total', 'Percent'])
missing_data.head(20)

Heat map

Nice pyplot show in pycharm

Create configure python file

ipython profile create
ipython profile locate

Open Configure file

1. Error

1. XGBoost Install Error

https://stackoverflow.com/a/43101972/2776008
brew install gcc --without-multilib
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/config.mk ./config.mk
private let swizzling: (AnyClass, Selector, Selector) -> () = { forClass, originalSelector, swizzledSelector in
let originalMethod = class_getInstanceMethod(forClass, originalSelector)
let swizzledMethod = class_getInstanceMethod(forClass, swizzledSelector)
method_exchangeImplementations(originalMethod!, swizzledMethod!)
}
extension UIViewController {
static let swizzled: Void = {
let originalSelector = #selector(viewDidLoad)
let swizzledSelector = #selector(swizzled_viewDidload)