Skip to content

Instantly share code, notes, and snippets.

View bagus2x's full-sized avatar
🎯
Focusing

tubagus saifulloh bagus2x

🎯
Focusing
View GitHub Profile
@bagus2x
bagus2x / ExoPlayerState.kt
Created March 19, 2023 06:46
Observe exoplayer state / Player.Listener in jetpack compose
class ExoPlayerState(
context: Context,
private val scope: CoroutineScope
) : ExoPlayer by ExoPlayer.Builder(context).build(), Player.Listener {
@get:JvmName("playing")
var isPlaying by mutableStateOf(false)
private set
var duration by mutableStateOf(0.seconds)
private set
var currentPosition by mutableStateOf(0.seconds)
@bagus2x
bagus2x / TwitterDatePicker.kt
Created March 22, 2023 18:16
Jetpack compose twitter date picker (dob). Jetpack Compose scrollable date picker.
package bagus2x.sosmed.presentation.common.components
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.pager.VerticalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.MaterialTheme
@bagus2x
bagus2x / null.go
Created April 28, 2023 15:59
Golang nullable with generic
type Null[T any] struct {
Value T
Valid bool
Set bool
}
func (n *Null[T]) UnmarshalJSON(data []byte) error {
n.Set = true
if string(data) == "null" {
@bagus2x
bagus2x / rest-client.ts
Last active December 6, 2023 08:42
Useful rest client interceptor with next-auth 5 and nextjs fetch.
import { auth } from '@pengode/auth'
const getBearer = async () => {
const session = await auth()
if (!session?.user.accessToken) return
return `Bearer ${session.user.accessToken}`
}
@bagus2x
bagus2x / README.md
Last active April 11, 2024 12:34
README.md

Hi 👋, I'm Tubagus

A passionate frontend developer from Indonesia

bagus2x

Connect with me:

Languages and Tools: