Skip to content

Instantly share code, notes, and snippets.

View pavlospt's full-sized avatar
💻
Refactoring something somewhere

Pavlos-Petros Tournaris pavlospt

💻
Refactoring something somewhere
View GitHub Profile
@pavlospt
pavlospt / gist:af6cd312a0832f69fb602af06afa20ef
Created February 12, 2024 12:31
SSM Parameter loading (GetParametersAPI)
Number of requests: 42
##########################################
Starting to fetch parameters from futures!
Time spent for a chunk: 312ms
Time spent for a chunk: 318ms
Time spent for a chunk: 319ms
Time spent for a chunk: 318ms
Time spent for a chunk: 320ms
Time spent for a chunk: 321ms
Time spent for a chunk: 321ms
g": 0}
arc-gha-rs-controller-55db6fd4c8-4lnrd manager 2023-12-08T10:49:23Z INFO EphemeralRunnerSet Scaling comparison {"ephemeralrunnerset": {"name":"arc-runner-set-85ndg","namespace":"github-arc-runners"}, "current": 5, "desired": 5}
arc-gha-rs-controller-55db6fd4c8-4lnrd manager 2023-12-08T10:49:23Z INFO AutoscalingRunnerSet Find existing ephemeral runner set {"autoscalingrunnerset": {"name":"arc-runner-set","namespace":"github-arc-runners"}, "name": "arc-runner-set-85ndg", "specHash": "68f7894"}
arc-gha-rs-controller-55db6fd4c8-4lnrd manager 2023-12-08T11:09:46Z INFO EphemeralRunnerSet Ephemeral runner counts {"ephemeralrunnerset": {"name":"arc-runner-set-85ndg","namespace":"github-arc-runners"}, "pending": 0, "running": 5, "finished": 0, "failed": 0, "deleting": 0}
arc-gha-rs-controller-55db6fd4c8-4lnrd manager 2023-12-08T11:09:46Z INFO EphemeralRunnerSet Scaling comparison {"ephemeralrunnerset": {"name":"arc-runner-set-85ndg","namespace":"github-arc-runners"}, "current": 5, "desired": 5}
arc-gha-rs-contr
@pavlospt
pavlospt / settings.gradle.kts
Created August 20, 2020 09:03
Automatically discover modules
/**
* Dynamically discover and add modules in our project
* */
val moduleBuildFileName = "build.gradle.kts"
// A pattern to match the prefix of our modules
val eligibleModuleNamePattern = "a_pattern_to_match_our_module_names".toRegex() // (e.g.: (app|android-|kotlin-).*)
// Filter directories that indicate modules
val moduleFilter: FileFilter = FileFilter { pathname: File ->
@pavlospt
pavlospt / ResultUseCase.kt
Created May 2, 2020 10:41
ResultUseCase.kt
abstract class ResultUseCase<Type, in Params> where Type : Any {
protected abstract val workDispatcher: CoroutineDispatcher
abstract suspend fun run(params: Params): Result<Type>
suspend operator fun invoke(params: Params): Result<Type> = withContext(workDispatcher) {
run(params)
}
}
@pavlospt
pavlospt / NoResultUseCase.kt
Created May 2, 2020 10:34
NoResultUseCase.kt
abstract class NoResultUseCase<in Params> {
protected abstract val workDispatcher: CoroutineDispatcher
abstract suspend fun run(params: Params)
suspend operator fun invoke(params: Params) = withContext(workDispatcher) {
run(params)
}
}
@pavlospt
pavlospt / FlowUseCase.kt
Last active May 3, 2020 14:16
FlowUseCase.kt
interface ObservableUseCase<Type> {
val dispatcher: CoroutineDispatcher
fun observe(): Flow<Type>
}
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
abstract class FlowUseCase<Type : Any, Params : Any> : ObservableUseCase<Type> {
private val channel = ConflatedBroadcastChannel<Params>()
operator fun invoke(params: Params) = channel.sendBlocking(params)
class OurViewModel(observeGithubReposUseCase: ObserveGithubReposUseCase): ViewModel {
val githubRepos: LiveData<List<GithubRepoItem>>
get() = observeGithubReposUseCase
.observe()
.map { reposList ->
reposList
.sortedByDescending { it.stars }
.map {
class OurViewModel: ViewModel() {
private val _intentChannel = ConflatedBroadcastChannel<OurViewIntent>()
init {
_intentChannel
.asFlow()
.onEach { viewIntent ->
when (viewIntent) {
OurViewIntent.Refresh -> refreshData()
}
@Suppress("UNCHECKED_CAST")
class ViewModelFactory @Inject constructor(
private val creators: Map<Class<out ViewModel>, Provider<ViewModel>>
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
val creator = creators[modelClass]
?: creators.asIterable().find { (key, _) -> modelClass.isAssignableFrom(key) }?.value
?: throw IllegalArgumentException("Unknown ViewModel class $modelClass")
import org.koin.dsl.module
val usecaseModule = module {
factory {
RefreshGithubReposUseCase(
appCoroutineDispatchers = get(),
githubRemoteRepo = get(),
githubLocalRepo = get()
)
}