This file contains 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
class Rest { | |
static apiBaseUrl = ''; | |
static getApiHeader({withoutContentType = false} = {}) { | |
const header = {}; | |
header['reqVersion'] = 2; | |
// if (authentic) { | |
// header['Authorization'] = this.getAuthToken(); | |
// } |
This file contains 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
// extends ajax | |
$.ajax = (($oldAjax) => { | |
var df = $.Deferred(); | |
// on fail, retry by creating a new Ajax deferred | |
function check(self, status) { | |
console.log("check " + status + " => " + self.retries); | |
const shouldRetry = status != 'success' && status != 'parsererror'; | |
if (shouldRetry && self.retries > 0) { | |
setTimeout(() => { | |
console.log("retry " + self.retries); |
This file contains 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
/// 바인딩 | |
private var observations: [NSKeyValueObservation] = [] | |
private var viewModel = ExpenseViewModel() | |
// 뷰 바인딩 | |
observations = [ | |
viewModel.observe(\.price) { | |
let price = $0 ?? 0.0 | |
self.updatePriceText(with: price) | |
self.changesPublisher.onNext(1) |
This file contains 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
class ExpenseViewModel: NSObject { | |
@objc dynamic var price = -1.0 | |
@objc dynamic var title = "" | |
@objc dynamic var text: String? = nil | |
} |
This file contains 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
extension NSObjectProtocol where Self: NSObject { | |
func observe<Value>(_ keyPath: KeyPath<Self, Value>, | |
onChange: @escaping (Value?) -> Void) -> NSKeyValueObservation { | |
return observe(keyPath, options: [.initial, .new]) { _, change in | |
onChange(change.newValue) | |
} | |
} | |
func bind<Value, Target>(_ sourceKeyPath: KeyPath<Self, Value>, |
This file contains 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
Scheduler scheduler = Schedulers.newThread(); | |
Scheduler.Worker worker = scheduler.createWorker(); | |
worker.schedule(() -> { | |
result += "First_Action"; | |
worker.unsubscribe(); | |
}); | |
worker.schedule(() -> result += "Second_Action"); | |
Assert.assertTrue(result.equals("First_Action")); |
This file contains 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
Scheduler scheduler = Schedulers.immediate(); | |
Scheduler.Worker worker = scheduler.createWorker(); | |
worker.schedule(() -> result += "action"); | |
Assert.assertTrue(result.equals("action")); |
This file contains 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
func fetchCoachingRoom(complete: @escaping (Error?) -> Void) { | |
refreshCoachingRoomStatus = .working | |
cancellableCoachingRoom?.cancel() | |
cancellableCoachingRoom = apiService.stream(Api.getCoachingRoom()) | |
.map({ (res) -> [AClass] in | |
return res.userClassList | |
}) | |
.receive(on: DispatchQueue.main) | |
.map { [weak self] list -> [Int] in | |
self?.coachingRoomClasses = list |
This file contains 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
// Hugo Elias Water 2D Effect | |
let COLUMNS = 40; | |
let ROWS = 40; | |
let BLOCKS = COLUMNS * ROWS; | |
let LEVEL = 50; | |
let HIGH_LEVEL = LEVEL * 2; | |
let HUE = 210; | |
let SATU = 95; |
This file contains 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
// activity with android:windowSoftInputMode="stateHidden" | |
private fun showPasswordDialog() { | |
val context = this.context ?: return | |
val editText = EditText(context) | |
editText.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD | |
editText.filters = arrayOf(InputFilter.LengthFilter(4)) | |
val frame = FrameLayout(context) | |
frame.addView(editText) |