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
| /* | |
| * Created by nphau on 09/12/2021, 00:30 | |
| * Copyright (c) 2021 . All rights reserved. | |
| * Last modified 09/12/2021, 15:54 | |
| */ | |
| public int solution(int[] numbers) { | |
| Arrays.sort(numbers); | |
| int min = 1; | |
| for (int i : numbers){ |
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
| /* | |
| * Created by nphau on 09/12/2021, 00:30 | |
| * Copyright (c) 2021 . All rights reserved. | |
| * Last modified 09/12/2021, 15:54 | |
| */ | |
| fun solution(numbers: IntArray): Int { | |
| val n = numbers.size | |
| val present = BooleanArray(n + 1) | |
| numbers.forEach { number -> |
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
| // Use "PBKDF2WithHmacSHA512" with android O version and above | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| val skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512") | |
| val pwSpec = PBEKeySpec(secret.toCharArray(), salt, iterations, keyLength) | |
| skf.generateSecret(pwSpec).encoded | |
| } |
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
| Algorithm | Supported API Levels | |
|---|---|---|
| AES | 23+ | |
| DES | 1+ | |
| DESede | 1+ | |
| HmacSHA1 | 23+ | |
| HmacSHA224 | 23+ | |
| HmacSHA256 | 23+ | |
| HmacSHA384 | 23+ | |
| HmacSHA512 | 23+ | |
| PBEwithHmacSHA1 | 1+ |
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 io.ktor.features.* | |
| // ... | |
| fun main() { | |
| private val server by lazy { | |
| embeddedServer(Netty, PORT, watchPaths = emptyList()) { | |
| // configures Cross-Origin Resource Sharing. CORS is needed to make calls from arbitrary | |
| // JavaScript clients, and helps us prevent issues down the line. | |
| install(CORS) { | |
| anyHost() | |
| } |
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
| dependencies { | |
| //... | |
| // Coroutines | |
| implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" | |
| // Embedded Server | |
| implementation 'io.ktor:ktor-server-core:2.2.4' | |
| implementation 'io.ktor:ktor-server-netty:2.2.4' | |
| implementation 'io.ktor:ktor-serialization-kotlinx-json:2.2.4' | |
| implementation 'io.ktor:ktor-client-content-negotiation:2.2.4' |
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
| companion object { | |
| private const val PORT = 5001 | |
| } | |
| private val server by lazy { | |
| embeddedServer(Netty, PORT, watchPaths = emptyList()) { | |
| install(WebSockets) | |
| install(CallLogging) | |
| routing { | |
| get("/") { | |
| call.respondText( |
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
| >>> x_train, x_test, y_train, y_test = train_test_split( | |
| ... x, y, test_size=4, random_state=4 | |
| ... ) | |
| >>> x_train | |
| array([[17, 18], | |
| [ 5, 6], | |
| [23, 24], | |
| [ 1, 2], | |
| [ 3, 4], | |
| [11, 12], |
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
| # COSIN DISTANCES | |
| # SOLUTION 1: | |
| import numpy as np | |
| vector_1 = np.array([1, 5, 1, 4, 0, 0, 0, 0, 0]) | |
| vector_2 = np.array([2, 4, 1, 1, 1, 1, 0, 0, 0]) | |
| def cos_sim(a, b): | |
| """Takes 2 vectors a, b and returns the cosine similarity | |
| """ | |
| dot_product = np.dot(a, b) # x.y |
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
| private_lane :bundle do |options| | |
| mode = (options[:mode]) | |
| yarn(command: "android:bundle:#{mode}") | |
| sh("rm -rf ../android/app/src/main/res/drawable-*") | |
| sh("rm -rf ../android/app/src/main/res/raw") | |
| sh("cp -a ../app/assets/android/* ../android/app/src/main/res") | |
| end |
NewerOlder