Skip to content

Instantly share code, notes, and snippets.

View quocnb's full-sized avatar
♟️

Quoc Nguyen quocnb

♟️
View GitHub Profile
import UIKit
class MarginLabel: UILabel {
var insets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
override func drawText(in rect: CGRect) {
super.drawText(in: rect.inset(by: insets))
}
public struct URLCredentialHelper {
enum URLCredentialError {
static let invalidUrl = NSError(domain: NSURLErrorDomain, code: NSURLErrorBadURL, userInfo: nil)
}
static func store(user: String, password: String, url: String) throws {
let protectionSpace = try createProtectionSpace(for: url)
let credentital = URLCredential(user: user, password: password, persistence: .permanent)
URLCredentialStorage.shared.set(credentital, for: protectionSpace)
}
extension Sequence {
func forEach(_ closure: (Element) -> () -> Void) {
for element in self {
closure(element)()
}
}
}
let arr = [view1, view2]
arr.forEach(UIView.removeFromSuperview)
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)

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

Nice pyplot show in pycharm

Create configure python file

ipython profile create
ipython profile locate

Open Configure file

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

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

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.