Skip to content

Instantly share code, notes, and snippets.

View oguzhanaslann's full-sized avatar
🎯
Focusing

Oğuzhan Aslan oguzhanaslann

🎯
Focusing
View GitHub Profile
@oguzhanaslann
oguzhanaslann / csv_to_jsonl.py
Last active May 26, 2025 11:36
Simple function to convert csv file into jsonl files written in python
import csv
import json
import argparse
def convert_csv_to_jsonl(input_csv, output_jsonl):
try:
# Open the CSV file
with open(input_csv, 'r', encoding='utf-8') as csv_file:
# Read CSV file
csv_reader = csv.DictReader(csv_file)
import com.thelifeco.wannawell.data.netwok.MutableTokenProvider
import com.thelifeco.wannawell.utils.AppUtils
import com.thelifeco.wannawell.utils.extension.EMPTY
@JvmInline
value class Key(val value: String)
interface MemorySource: MutableTokenProvider {
fun <T> save(key: Key, value: T)
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
object IsoDateFormatter {
const val FULL_DAY_NAME = "EEEE"
const val ABBR_DAY_NAME = "EEE"
const val DAY_OF_THE_MONTH = "dd"
@oguzhanaslann
oguzhanaslann / MarginState.kt
Last active April 17, 2025 10:10
WindowInsetsControllerCompat wrapper class to simplify the interface of it
/**
* Data class to hold margin states
*/
data class MarginState(
val left: Int,
val top: Int,
val right: Int,
val bottom: Int
)
@oguzhanaslann
oguzhanaslann / ZipFacade.kt
Created November 26, 2023 16:18
Zip helper for Android
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream
object ZipFacade {
import android.content.Context
import android.text.Layout
import android.text.method.LinkMovementMethod
import android.util.AttributeSet
import android.util.Log
import androidx.appcompat.widget.AppCompatTextView
import com.thelifeco.wannawell.R
import com.thelifeco.wannawell.utils.extension.spannableString
class ExpandableTextView @JvmOverloads constructor(
import android.content.Context
import androidx.recyclerview.widget.LinearLayoutManager
class CenterScrollLayoutManager(val context: Context, orientation: Int, reverseLayout: Boolean) :
LinearLayoutManager(context, orientation, reverseLayout) {
constructor(context: Context) : this(context, HORIZONTAL, false)
override fun scrollToPosition(position: Int) {
val offset = calculateOffsetForPosition(position)
import android.graphics.Paint
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.ShapeDrawable
import android.graphics.drawable.shapes.RectShape
import android.graphics.drawable.shapes.RoundRectShape
import android.graphics.drawable.shapes.Shape
class ShapeDrawableBuilder {
private var shape: Shape? = null
interface Logger {
fun d(tag: String, msg: String)
fun e(tag: String, msg: String, throwable: Throwable? = null)
fun i(tag: String, msg: String)
fun w(tag: String, msg: String)
}
@oguzhanaslann
oguzhanaslann / given_when_then_testing.kt
Created July 30, 2023 10:56
test helper functions in "given-when-then" for better readability
data class Given<T>(val state: T)
data class When<T>(val scenario: T)
data class Then<T>(val result: T)
fun <T> given(block: () -> T) = Given<T>(block())
infix fun <T, R> Given<T>.check(block: (T) -> R): When<R> {
val state = this.state