Skip to content

Instantly share code, notes, and snippets.

View ThanosFisherman's full-sized avatar

Thanos Psaridis ThanosFisherman

View GitHub Profile
@Razeeman
Razeeman / Singletons.md
Last active February 23, 2025 03:15
Thread safe singleton implementations in java and kotlin.

Java

Not thread safe.

class SimpleSingleton {
    private static SimpleSingleton sInstance;
  
    private SimpleSingleton() {}
 
@umpteenthdev
umpteenthdev / SendMultipart.kt
Last active July 17, 2025 18:01
Ktor Client. How to send byteArray using multipart/form data
import io.ktor.client.HttpClient
import io.ktor.client.call.call
import io.ktor.client.engine.okhttp.OkHttp
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.forms.formData
import io.ktor.client.request.url
import io.ktor.http.Headers
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import kotlinx.coroutines.GlobalScope
@anitaa1990
anitaa1990 / NetworkBoundSource.kt
Created December 24, 2018 05:56
NetworkBoundSource.kt using RxJava/RxAndroid
/* NetworkBoundSource - using Observable in RxJava/RxAndroid */
abstract class NetworkBoundResource<ResultType, RequestType> @MainThread
protected constructor() {
private val asObservable: Observable<Resource<ResultType>>
init {
val source: Observable<Resource<ResultType>>
if (shouldFetch()) {
@dakatso
dakatso / klog.kt
Last active November 15, 2019 08:29
Koltin android log extension
fun klog(@IntRange(from = 2, to = 6) level: Int, message: Any?) {
if (!BuildConfig.DEBUG) return
Throwable().stackTrace[1].run {
val tag = "commontag"
val fullMessage = "($fileName:$lineNumber): $message"
when (level) {
Log.VERBOSE -> Log.v(tag, fullMessage)
Log.DEBUG -> Log.d(tag, fullMessage)
Log.INFO -> Log.i(tag, fullMessage)
Log.WARN -> Log.w(tag, fullMessage)
@nieldeokar
nieldeokar / AudioRecordThread.java
Last active December 26, 2025 22:30
Recording an Audio with .aac extension using AudioRecord android.
package com.nieldeokar.whatsappaudiorecorder.recorder;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.os.Build;
import android.util.Log;
@ArthurNagy
ArthurNagy / RoundedBottomSheetDialogFragment.kt
Last active November 2, 2025 09:21
Rounded modal bottom sheet as seen in new Google products(Tasks, News, etc.), described in this article: https://medium.com/halcyon-mobile/implementing-googles-refreshed-modal-bottom-sheet-4e76cb5de65b
package com.your.package
import android.app.Dialog
import android.os.Bundle
import com.your.package.R
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
* BottomSheetDialog fragment that uses a custom
@ValCanBuild
ValCanBuild / BottomNavigationBehavior.kt
Last active December 18, 2023 00:04
Full code of a BottomNavigationBehavior which hides itself on scroll and handles Snackbars, FAB and snapping. https://medium.com/@ValCanBuild/scroll-your-bottom-navigation-view-away-with-10-lines-of-code-346f1ed40e9e
/**
MIT License
Copyright (c) 2018 Valentin Hinov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@arnaudgiuliani
arnaudgiuliani / JavaApp.java
Created February 27, 2018 16:04
Koin for Android Java app
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Call helper to start Koin
JavaAppKoinKt.start(this);
}
}
@JakubPetriska
JakubPetriska / quotes.csv
Last active May 7, 2026 10:47
Motivational quotes
Author Quote
Thomas Edison Genius is one percent inspiration and ninety-nine percent perspiration.
Yogi Berra You can observe a lot just by watching.
Abraham Lincoln A house divided against itself cannot stand.
Johann Wolfgang von Goethe Difficulties increase the nearer we get to the goal.
Byron Pulsifer Fate is in your hands and no one elses
Lao Tzu Be the chief but never the lord.
Carl Sandburg Nothing happens unless first we dream.
Aristotle Well begun is half done.
Yogi Berra Life is a learning experience, only if you learn.
package com.google.firebase.udacity.friendlychat
import com.google.firebase.database.ChildEventListener
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
class _ChildEventListener(
private val _onCancelled: (DatabaseError) -> Unit,
private val _onChildMoved: (DataSnapshot, String?) -> Unit,
private val _onChildChanged: (DataSnapshot, String?) -> Unit,