Skip to content

Instantly share code, notes, and snippets.

View kafri8889's full-sized avatar
😭
Student

Anaf Naufalian kafri8889

😭
Student
View GitHub Profile
@kafri8889
kafri8889 / PeerpusSimulation.py
Created January 27, 2024 13:04
Tugas OOP Coding AP 1 B
import random
import time
# OOP perpus
# @author: kafri8889
# Template nama orang
nameTemplate = [
"Wang Yiren",
"Bai Lu",
@kafri8889
kafri8889 / SystemBarsController.kt
Created December 23, 2023 15:26
System bars controller for android (Jetpack Compose)
import android.app.Activity
import android.content.ContextWrapper
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
@kafri8889
kafri8889 / py_prime_number.py
Last active October 19, 2023 09:01
Check if given number is prime or not
"""
Pertama, buat function yang bernama "isPrimeNumber".
Apa itu ffunction?
Singkatnya function/method adalah suatu blok kode yang melakukan tugas tertentu (sesuai programmernya mau bikin apaan).
salahh satu kegunaan function adl bisa mengurangi boilerplate code (kode yang dipakai berulang kali tanpa perbedaan)
Flownya kayak gini:
INPUT => EKSEKUSI KODE => OUTPUT (opsional)
@kafri8889
kafri8889 / python_prime_number.py
Created October 10, 2023 13:59
Cek apakah angka prima atau bukan di python
def isPrimeNumberAndPrint(n):
for i in range(2, n):
if n % i == 0:
print(n, "bukan bilangan prima, karena bisa dibagi dengan", n//i)
return
print(n, "adalah bilangan prima")
@kafri8889
kafri8889 / Unre.kt
Created July 27, 2023 11:04
Class for undo/redo feature (linked list)
class Unre<T> {
class UnreListNode<T>(var value: T) {
var next: UnreListNode<T>? = null
var prev: UnreListNode<T>? = null
override fun toString(): String {
return "ListNode(${value}, ${next?.toString()})"
}
}
@kafri8889
kafri8889 / Unre.kt
Created February 19, 2023 10:46
Undo redo feature
class Unre<T> {
private var listener: UnreListener<T>? = null
val stacks: ArrayList<UnreData<T>> = arrayListOf()
var currentStack: Int = -1
private fun modifyStack() {
val newStacks = arrayListOf<UnreData<T>>()
@kafri8889
kafri8889 / BubbleNotification.kt
Last active December 31, 2023 12:56
BubbleNotification, similar to Snackbar, is on top with enter/exit slide animation
@Composable
fun BubbleNotificationHost(
hostState: BubbleNotificationHostState,
modifier: Modifier = Modifier,
animationSpec: FiniteAnimationSpec<IntOffset> = tween(300),
bubbleNotification: @Composable (BubbleNotificationData) -> Unit = { BubbleNotification(it) },
content: @Composable () -> Unit
) {
val currentBubbleNotificationData = hostState.currentBubbleNotificationData
@kafri8889
kafri8889 / transformationExmpl.kt
Last active August 14, 2022 00:38
Remove audio from video with ExoPlayer
// inside the composable function
val context = LocalContext.current
var exoPlayer by remember { mutableStateOf<ExoPlayer?>(null) }
val transformerListener = remember {
object : Transformer.Listener {
override fun onTransformationCompleted(inputMediaItem: MediaItem, transformationResult: TransformationResult) {
super.onTransformationCompleted(inputMediaItem, transformationResult)
@kafri8889
kafri8889 / PickerManager.kt
Last active July 22, 2022 02:41
class for picker dialog
/**
@author kafri8889
**/
class PickerManager(
private val context: FragmentActivity,
private val listener: PickerListener
) {
fun datePicker(
data: Any? = null,
@Composable
fun SettingPreference(
preference: Preference,
onClick: (Any) -> Unit
) {
when (preference) {
is BasicPreference -> {
BasicPreference(
preference = preference,
onClick = onClick