Skip to content

Instantly share code, notes, and snippets.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD3MouNWfFPnLGppQudUz2y3azP8yinWRxla/Y3nfjO1h9pHJWFnFoFP44dPgDbrHAVgkHD7VNteHVE4nU58eQbbKgy+4DllzNVt4AWbDAN1GskhpbY0oe+YKotn54yKoIxzJiTdK/PiGFPxZGszie8SHVrI1c4RMT/Xkg8Xv0pXFtc4p1vOuJqaUl5U57Aayj7oZ5J59qtp3vUFLqsMp4CbvczLDkcCjkPDbRYfYPSqETabkDrtCnFMoSWVCBimEuSR6NTFIzcb1hFVpaKKTJUIylVjQujfJMyyHAY9FojRu16K4hBYa10dlVRtmt/+LI8WYfPfLaE+RD1mRtrNKKq/vO4panTjNRtFDah1TX8QvUHbJ/PNj/bBM/8ZPwVaDldiG3M7yPSO+qqLj7V4p7qp7K+QjbGaTQZSXm1QReqy3Qq85q7yW2DK7L5DtBQopIuPdAabc1inFF3CN1S6+W0+B03PQWKmL83mp27xqtZ/n++9Ni3aCv/oKPUZ/OaqaU= [email protected]
import os
import pathlib
from subprocess import PIPE, run
def renameFile(file, root) -> str:
new_filename = file.replace(" ", "")
os.rename(os.path.join(root, file), os.path.join(root, new_filename))
return new_filename
@karntrehan
karntrehan / CharacterDetailsVM.kt
Created July 21, 2019 08:09
SWAPI character details complex chain using Rx
package com.karntrehan.starwars.characters.details
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.karntrehan.starwars.architecture.BaseVM
import com.karntrehan.starwars.characters.details.models.CharacterDetailsModel
import com.karntrehan.starwars.characters.details.models.FilmDetailsModel
import com.karntrehan.starwars.characters.details.models.SpeciesDetailsModel
import com.karntrehan.starwars.characters.details.models.response.HomeworldResponseModel
import com.karntrehan.starwars.extensions.divide
@karntrehan
karntrehan / ListAdapterTemplate.java
Last active April 23, 2019 06:30
Java ListAdapter template for RecyclerView in Android
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
@karntrehan
karntrehan / ListAdapterTemplate.kt
Last active December 25, 2021 12:48
Kotlin ListAdapter template for RecyclerView in Android
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.View.OnClickListener
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
@karntrehan
karntrehan / DataFragment.kt
Created March 4, 2019 11:03
NestedScrollView + Paginated Recyclerview Android
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.core.view.ViewCompat
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.fragment_data.nsvData
import kotlinx.android.synthetic.main.fragment_data.rvData
@karntrehan
karntrehan / OpenSourceAndroidLibs.md
Created June 22, 2018 06:27
A list of Open source Android libs for the round table discussion at the June 2018 MADMeetup.
@karntrehan
karntrehan / Synk.kt
Last active July 26, 2019 06:32
Synk: A simple Kotlin file to abstract a hybrid syncing technique for your Android apps
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
import org.joda.time.DateTime
import org.joda.time.format.ISODateTimeFormat
import java.util.concurrent.TimeUnit
/**
* A Singleton object to identify if a sync operation should run or not.
* */