Skip to content

Instantly share code, notes, and snippets.

View prashantwosti's full-sized avatar
🏠
WFH

Prashant Wosti prashantwosti

🏠
WFH
View GitHub Profile
@c5inco
c5inco / SwipeableCards.kt
Last active April 21, 2024 13:06
Jetpack Compose implementation of inspiration: https://twitter.com/philipcdavis/status/1534192823792128000
package des.c5inco.cardswipecompose
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.calculateTargetValue
import androidx.compose.animation.core.keyframes
import androidx.compose.animation.splineBasedDecay
@DavidIbrahim
DavidIbrahim / DashedBorder.kt
Last active April 17, 2024 13:32
dashedBorder modifier for android compose
import androidx.compose.foundation.BorderStroke
/*
* 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
@andijakl
andijakl / WebAccess.kt
Created January 24, 2019 21:32
Retrofit instance created through Singleton pattern in Kotlin using lazy initialization
package com.andresjakl.partslist
import android.util.Log
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
// Singleton pattern in Kotlin: https://kotlinlang.org/docs/reference/object-declarations.html#object-declarations
object WebAccess {
val partsApi : PartsApiClient by lazy {
open class BaseRepository{
suspend fun <T : Any> safeApiCall(call: suspend () -> Response<T>, errorMessage: String): T? {
val result : Result<T> = safeApiResult(call,errorMessage)
var data : T? = null
when(result) {
is Result.Success ->
data = result.data
@NickHolcombe
NickHolcombe / ListAdapterWithHeader.kt
Last active October 18, 2023 00:16
Example of a RecyclerView Adapter based on ListAdapter with a header
package example
import android.support.v7.recyclerview.extensions.AsyncDifferConfig
import android.support.v7.recyclerview.extensions.AsyncListDiffer
import android.support.v7.util.DiffUtil
import android.support.v7.util.ListUpdateCallback
import android.support.v7.widget.RecyclerView
/**
* {@link RecyclerView.Adapter RecyclerView.Adapter} base class based on
@alejandro-martin
alejandro-martin / multiple-ssh-keys-git.adoc
Last active April 26, 2024 10:31
Configure multiple SSH Keys for Git

Use Multiple SSH Keys for Git host websites (Github, Gitlab)

This is guide about how to configure multiple SSH keys for some Git host websites such as Github, Gitlab, among others.

Creating SSH keys

  1. Create SSH directory:

@nethoncho
nethoncho / raspbian-list-open-ports.sh
Last active February 22, 2023 14:29
Raspberry Pi Raspbian list open ports
netstat -lnt | grep LISTEN | awk '{ print ( $4 ) }' | awk 'BEGIN{FS=":"} { print $(NF) }' | sort -n | uniq
@oakkub
oakkub / DialogExtensions.kt
Last active December 27, 2023 04:32
Kotlin extension functions for creating AlertDialog in a DSL way
import android.annotation.SuppressLint
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.support.annotation.StringRes
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.TextView
@Pulimet
Pulimet / AdbCommands
Last active April 25, 2024 19:40
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@alapshin
alapshin / ProxyBottomSheetBehavior.java
Created March 18, 2017 15:00
BottomSheetBehavior with support for multiple callbacks
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.util.AttributeSet;
import android.view.View;
import java.util.ArrayList;
/**
* Wrapper around {@link BottomSheetBehavior} with support for multiple callbacks.