Skip to content

Instantly share code, notes, and snippets.

View enginebai's full-sized avatar
📈
Focusing, Learning, Improving, Evolving

Engine Bai enginebai

📈
Focusing, Learning, Improving, Evolving
View GitHub Profile
@Single
data class KoinBridge(
val xxx: XXXRepository,
...
) {
init {
startKoin {
modules(
module {
single { xxx }
@Singleton
@Component(
modules = [
AppModule::class
]
)
interface AppComponent {
fun inject(activity: MainActivity)
}
import os
from bark import SAMPLE_RATE, generate_audio
from bark.generation import (
preload_models
)
from scipy.io.wavfile import write as write_wav
import nltk
import numpy as np
import argparse
object Worker {
var total = 0
fun accumulate() {
for (i = 0; i < 10000; i++) {
total = total + 1
}
}
fun doWork() {
List<User> userList = ...
List<Int> leaderAgesList = listOf()
for (User u : userList) {
if (u.title.contain('lead')) {
leaderAgesList.add(u.age)
}
}
Int sum = 0
override fun onDestroy() {
context = null
observable.dispose()
db.close()
connection.disconnect()
}
// Try not to do this!
try {
val response = api.fetchUser(userId)
} catch (exception) {
// skip the error
}
try {
val response = api.fetchUser(userId)
} catch (e) {
class RoundedBorderButton : Button {
String title;
Double radius;
Double textSize;
Color textColor;
Color borderColor;
...
}
class RoundedBorderButton : Button {
String text;
...
}
class Version {
var major: Int?
var minor: Int?
var patch: Int?
fun String.toVersion(): Version? {
val split = this.split(".")
return Version(split[0].toInt(), split[1].toInt(), split[2].toInt())
}
}