Skip to content

Instantly share code, notes, and snippets.

View cutiko's full-sized avatar

Erick Navarro cutiko

View GitHub Profile
cutiko / SimplestPlaceholderFragment.kt
Last active October 1, 2021 18:58
Simplest Placeholder Fragment for testing navigation
View SimplestPlaceholderFragment.kt
class SimplestPlaceholderFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return TextView(requireContext()).apply {
gravity = Gravity.CENTER
cutiko /
Last active September 14, 2021 18:44
Sms login
import android.content.Context;
import android.content.ContextWrapper;
import android.util.Base64;
import android.util.Log;
import java.nio.charset.StandardCharsets;
cutiko / FunctionDefaultValue.kt
Created June 25, 2020 18:29
A function as default value for argument in function, the default value function has also argument, wonders of Kotlin
View FunctionDefaultValue.kt
class FunctionDefaultValue {
companion object {
fun main(args: Array<String>) {
val result = foo(2)
fun foo(int: Int, boolean: Boolean = bar(int)): String {
cutiko / FakeAdapter
Created May 7, 2020 21:12
Fake RecyclerView Adapter for testing purpose
View FakeAdapter
private class FakeAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = object :
RecyclerView.ViewHolder(TextView(parent.context)) {}
override fun getItemCount() = 100
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
(holder.itemView as? TextView)?.text = position.toString()
cutiko /
Created November 22, 2019 18:24
Git delete last commit

Removing the last commit

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

If you want to "uncommit" the commits, but keep the changes around for reworking, remove the "--hard": git reset HEAD^ which will evict the commits from the branch and from the index, but leave the working tree around.

If you want to save the commits on a new branch name, then run git branch newbranchname before doing the git reset.

ORIGINAL did fork but search didn't helped me

cutiko / CheckInternet.kt
Created October 28, 2019 13:18
Check if there is internet available
View CheckInternet.kt
private fun isNoInternet(context: Context): Boolean {
val connectionManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager
return connectionManager?.let {
it.getNetworkCapabilities(it.activeNetwork)?.run {
when {
hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> false
hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> false
cutiko / Copier.kt
Last active September 10, 2019 21:20
How does copy works on Kotlin
View Copier.kt
package copier
import java.util.*
class Copier {
companion object {
fun main(args: Array<String>) {
println("lets see default behaviour")
cutiko /
Created July 20, 2019 02:37
Adapter template for Android Studio
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
#set($model = $NAME.replace('sAdapter', ''))
#set($holder = $model+'Holder')
#set($item = $model.toLowerCase())
cutiko /
Created July 3, 2019 17:23
Restart Android App using ADB

Remember to replace com.domain.appname with your actual app package name

adb shell am force-stop com.domain.appname
adb shell am start -n com.domain.appname/com.domain.appname.MainActivity
cutiko / infinity.kt
Created June 6, 2019 15:02
Inifinity is a double
View infinity.kt
fun main(args: Array<String>) {
System.out.println("Lets buy beer")
fun buyBeer(beer : Double) = System.out.println("You are buying $beer beers and is more than one beer ${beer > 1}")