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
import XCTest | |
struct Point { | |
let x: Double | |
let y: Double | |
} | |
class RotatingCalipers { | |
// Calculate distance between two points | |
private func distance(_ p1: Point, _ p2: Point) -> Double { |
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
package com.example.delayemitter | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.flow.* | |
import kotlinx.coroutines.test.UnconfinedTestDispatcher | |
import kotlinx.coroutines.test.runTest | |
import org.junit.Assert.assertEquals | |
import org.junit.Test | |
import java.lang.Thread.sleep | |
import java.util.* |
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
import UIKit | |
func printMessage() async { | |
let max: UInt32 = 4 | |
let min: UInt32 = 0 | |
let myRange: Range = min..<max | |
let string = await withTaskGroup(of: String.self) { group -> String in | |
group.addTask { | |
sleep(UInt32.random(in: myRange)) | |
return "Hello" |
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
struct PageControl: View { | |
@Binding var selectedPage: Int | |
var pages: Int | |
var circleDiameter: CGFloat | |
var circleMargin: CGFloat | |
var body: some View { |
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
import SwiftUI | |
// Move me to MDL | |
struct CardView: View { | |
let record: Record | |
var body: some View { | |
VStack(alignment: .leading) { |
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
// | |
// USDFRenewalPopupViewModelTests.swift | |
// ChiefTests | |
// | |
// Created by on_luk on 26/7/2022. | |
// | |
import XCTest | |
import Combine | |
@testable import ChiefMT |
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
import 'dart:collection'; | |
void main() { | |
// Q1 | |
bool ret = fx(2, 20, 200, 301); | |
print(" ${ ret ? "meet" : "not meet" }"); | |
ret = fx(2, 20, 4, 400); | |
print(" ${ ret ? "meet" : "not meet" }"); | |
print("O(?) step $step"); |
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
import RxSwift | |
import RxCocoa | |
//func ignoreNil<A>(x: A?) -> Observable<A> { | |
// return x.map { Observable.just($0) } ?? Observable.empty() | |
//} | |
func ignoreNil<A>(x: A?) -> Driver<A> { | |
return x.map { Driver.just($0) } ?? Driver.empty() |
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
import RxSwift | |
import RxCocoa | |
func ignoreNil<A>(x: A?) -> Observable<A> { | |
return x.map { Observable.just($0) } ?? Observable.empty() | |
} | |
// If there are values return from stream A, B and C then I emit an event on stream X (boolean) | |
func allEmitedValue<A, B, C>(_ a: Observable<A?>, _ b: Observable<B?>, _ c: Observable<C?>) -> Observable<Bool> { | |
Observable.combineLatest(a, b, c) { allContainValue($0, $1, $2) } |
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
import RxSwift | |
import RxCocoa | |
//func ignoreNil<A>(x: A?) -> Observable<A> { | |
// return x.map { Observable.just($0) } ?? Observable.empty() | |
//} | |
func ignoreNil<A>(x: A?) -> Driver<A> { | |
return x.map { Driver.just($0) } ?? Driver.empty() | |
} |
NewerOlder