Skip to content

Instantly share code, notes, and snippets.

View zakayothuku's full-sized avatar
👨‍💻
Opportunities don't respect sleep

Zakayo Thuku zakayothuku

👨‍💻
Opportunities don't respect sleep
View GitHub Profile
@stevdza-san
stevdza-san / RequestState.kt
Last active July 21, 2024 14:14
Useful wrapper class for handling the data in Jetpack Compose
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable
sealed class RequestState<out T> {
data object Idle : RequestState<Nothing>()
data object Loading : RequestState<Nothing>()
@Pasha831
Pasha831 / ModalBottomSheet.kt
Created January 25, 2023 13:17
ModalBottomSheetLayout for Material 3 Jetpack Compose
package com.hse.parkingapp.ui.beta.screens.components.material3
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@huuphuoc1396
huuphuoc1396 / jacoco.gradle
Last active May 4, 2022 18:53
Compiling with language version 1.5 breaks JaCoCo: "Unexpected SMAP line: *S KotlinDebug"
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jacocoFullReport'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$3(ExecuteActionsTaskExecuter.java:186)
Caused by: : Error while creating report
at org.jacoco.ant.ReportTask.execute(ReportTask.java:502)
Caused by: java.io.IOException: Error while analyzing PersonalRequestHelper.class.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:162)
Caused by: java.lang.IllegalStateException: Unexpected SMAP line: *S KotlinDebug
at org.jacoco.core.internal.analysis.filter.KotlinInlineFilter.getFirstGeneratedLineNumber(KotlinInlineFilter.java:98)
/**
* Navigates only if this is safely possible; when this Fragment is still the current destination.
*/
fun Fragment.navigateSafe(
@IdRes resId: Int,
args: Bundle? = null,
navOptions: NavOptions? = null,
navigatorExtras: Navigator.Extras? = null
) {
if (mayNavigate()) findNavController().navigate(
@vamjakuldip
vamjakuldip / ProgressLoading.kt
Last active December 28, 2020 12:02
Progress Loading Dialog
class ProgressLoading : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.apply {
requestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(R.layout.dialog_loading)
setCancelable(false)
window?.setBackgroundDrawable(ColorDrawable(android.graphics.Color.TRANSPARENT))
window?.setDimAmount(0f)
@zakayothuku
zakayothuku / pagination.js
Last active May 8, 2019 09:46 — forked from proudlygeek/pagination.js
Pagination Helper Kata
// http://www.codewars.com/kata/515bb423de843ea99400000a/train/javascript
// TODO: complete this object/class
// The constructor takes in an array of items and a integer indicating how many
// items fit within a single page
function PaginationHelper(collection, itemsPerPage){
this.collection = collection;
this.itemsPerPage = itemsPerPage;
}
@NiPfi
NiPfi / FirestoreRepository.java
Created April 18, 2018 07:36
Basic implementation of a repository pattern for Firebase Firestore
package ch.jojoni.jamplan.model.repository;
import android.support.annotation.NonNull;
import android.util.Log;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.DocumentReference;
@mg6maciej
mg6maciej / MoshiExtensions.kt
Created May 6, 2017 10:07
Moshi generic type adapters
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import java.lang.reflect.Type
// val adapter = moshi.listAdapter<MyModel>()
// val adapter = moshi.mapAdapter<String, List<MyModel>>(valueType = listType<MyModel>())
inline fun <reified E> Moshi.listAdapter(elementType: Type = E::class.java): JsonAdapter<List<E>> {
return adapter(listType<E>(elementType))
@lopspower
lopspower / README.md
Last active July 23, 2024 13:00
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@morrismukiri
morrismukiri / kenyanMobilePhoneRegEx.txt
Last active July 21, 2024 08:10
Kenyan phone number regular expression
/(0|+?254)7(\d){8}/