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
@FaizVisram
FaizVisram / EmailPreference.java
Last active January 4, 2022 15:20
A custom Preference that opens a new email in the user's default email app.
package com.faizvisram.android.preference;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.preference.Preference;
import android.util.AttributeSet;
/**
* Created by Faiz Visram.
@proudlygeek
proudlygeek / pagination.js
Created July 15, 2014 11:17
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.items = collection;
this.itemsPerPage = itemsPerPage;
}
@morrismukiri
morrismukiri / kenyanMobilePhoneRegEx.txt
Last active October 21, 2024 07:51
Kenyan phone number regular expression
/(0|+?254)7(\d){8}/
@lopspower
lopspower / README.md
Last active November 14, 2024 08:32
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

@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))
@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;
@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;
}
@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)
/**
* 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(
@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)