Skip to content

Instantly share code, notes, and snippets.

code is fun

Henrique Horbovyi henrikhorbovyi

code is fun
View GitHub Profile
henrikhorbovyi / ServiceBuilder.kt
Created Jul 8, 2020
Service Builder for Retrofit
View ServiceBuilder.kt
* .:.:.:. Created on 07/10/19 .:.:.:.
interface ServiceBuilder {
companion object {
inline operator fun <reified S> invoke(baseUrl: String, authToken: String? = ""): S {
val httpClient = buildInterceptors(authToken)
return Retrofit.Builder()



apply plugin: 'androidx.navigation.safeargs'
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07"

implementation "androidx.navigation:navigation-fragment-ktx:2.0.0"
implementation "androidx.navigation:navigation-ui-ktx:2.0.0"

View Extensions.kt
// use >> 10.dp(context)
fun Int.dp(context: Context): Float {
return this * context.resources.displayMetrics.density
/* View Extensions */
// use >> bindView(
fun <V : View> Activity.bindView(@IdRes id: Int) = unsafeLazy { findViewById<V>(id) }
inline fun <T> unsafeLazy(noinline initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE, initializer)
View TestAdapter.kt
class TestListAdapter(private val context: Context) : RecyclerView.Adapter<TestListAdapter.ViewHolder>(){
private val data: MutableList<TestModel> = mutableListOf()
override fun getItemCount(): Int = data.count()
override fun onCreateViewHolder(parent: ViewGroup, p1: Int): ViewHolder {
val view = LayoutInflater.from(context).inflate(R.layout.list_Test, parent ,false)
return ViewHolder(view)
View TestModel.kt
data class TestModel(val id: Int = 0, val name: String? = null)
View TestActivity.kt
class TestActivity : AppCompatActivity() {
// you can use 'by lazy' in this case, and volley object will be instantiated only when needed
private val volleyRequest: RequestQueue by lazy { Volley.newRequestQueue(this) }
private val testList: MutableList<TestModel> = mutableListOf()
// you don't need to pass parameters, just need to change a bit the implementation of your Adapter class.
private val adapter: TestListAdapter = TestListAdapter(this)
// don't need to create this variable if you are not using more than 1 time
//private var layoutManager: RecyclerView.LayoutManager?=null
View multiple_file_upload.php
for($i=0; $i<count($_FILES['file']['name']); $i++) {
$tmpFilePath = $_FILES['file']['tmp_name'][$i];
$shortname = $_FILES['file']['name'][$i];
$filename = date('YmdHis').$_FILES['file']['name'][$i];
$filePath = "./public/course_work/".$filename;
$ext = pathinfo($_FILES['file']['name'][$i], PATHINFO_EXTENSION);
$file = basename($shortname,".".$ext);
View AddDividerOnRecyclerViewItem.kt
recyclerView.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
henrikhorbovyi / Github Emojis
Created Apr 6, 2016
Gihub emojis to improve my commits. :D
View Github Emojis
henrikhorbovyi /
Created Apr 4, 2016
A script to join in one place all services that I need in my environment.
if [ $service == 'lampp' ]
sudo /opt/lampp/./manager $action
sudo service $service $action