Skip to content

Instantly share code, notes, and snippets.

View andhikayuana's full-sized avatar
🌏
bertapa

Andhika Yuana andhikayuana

🌏
bertapa
View GitHub Profile
@andhikayuana
andhikayuana / Scrollbar.kt
Created July 24, 2024 08:59 — forked from mxalbert1996/Scrollbar.kt
Modifiers to draw scrollbars in Jetpack Compose
/*
* MIT License
*
* Copyright (c) 2022 Albert Chang
*
* 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
@andhikayuana
andhikayuana / Tooltip.kt
Created July 10, 2024 15:05 — forked from amal/Tooltip.kt
How to show a tooltip in AndroidX Jetpack Compose?
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
// Tooltip implementation for AndroidX Jetpack Compose
// See usage example in the next file
// Tested with Compose version **1.1.0-alpha06**
// Based on material DropdownMenu implementation.
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloat
@andhikayuana
andhikayuana / DatabaseQueueMonitorCommand.php
Created July 5, 2024 00:59 — forked from BenCavens/DatabaseQueueMonitorCommand.php
Laravel queue monitoring on shared hosting
<?php
namespace App\Queue;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class DatabaseQueueMonitorCommand extends Command
{
@andhikayuana
andhikayuana / build.gradle
Created June 29, 2024 19:36 — forked from MinceMan/build.gradle
Change output file name for Android with build.gradle
apply plugin: 'com.android.library'
/** This closure will rename your output file with your outputName, versionName and git commit. */
android.metaClass.renameVariants = { String moduleName, String outputName ->
def isApplication = binding.variables.containsKey('applicationVariants')
def variants = isApplication ? applicationVariants : libraryVariants
def gitCommit = "git rev-parse --short HEAD".execute().text.trim()
def ext = isApplication ? '.apk' : '.aar'
variants.all { -> outputs.each {
@andhikayuana
andhikayuana / MainActivity.kt
Created June 27, 2024 03:18 — forked from webserveis/MainActivity.kt
Show app usage with UsageStatsManager
import android.Manifest
import android.app.AppOpsManager
import android.app.usage.StorageStats
import android.app.usage.StorageStatsManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.os.Process
@andhikayuana
andhikayuana / youtube.md
Created June 20, 2024 12:50 — forked from bitsurgeon/youtube.md
Markdown cheatsheet for YouTube

Embed YouTube Video in Markdown File

  1. Markdown style
[![Watch the video](https://img.youtube.com/vi/nTQUwghvy5Q/default.jpg)](https://youtu.be/nTQUwghvy5Q)
  1. HTML style
<a href="http://www.youtube.com/watch?feature=player_embedded&v=nTQUwghvy5Q" target="_blank">
@andhikayuana
andhikayuana / write-fixer.py
Created April 18, 2024 03:18 — forked from ahmadrosid/write-fixer.py
Fixed typos, spelling mistakes, and grammar while maintaining clarity and a concise tone using Claude.
import sys
import anthropic
from dotenv import load_dotenv
load_dotenv()
client = anthropic.Anthropic()
prompt_template = """
Please review and edit the following text to ensure it is grammatically correct, clear, and concise. Aim to maintain a casual tone without being overly informal. Provide suggestions for improvement and explain any changes you make. Do not add double quotes in you rewrite answer. Answer in direct response.
@andhikayuana
andhikayuana / JsonRpc.kt
Created February 23, 2024 06:51 — forked from ntoskrnl/JsonRpc.kt
Retrofit-style JSON-RPC client in Kotlin (with gson serialization/deserialization)
fun <T, B> createJsonRpcService(service: Class<T>,
client: JsonRpcClient<B>,
resultDeserializer: Deserializer<B>,
logger: (String) -> Unit = {}): T {
val classLoader = service.classLoader
val interfaces = arrayOf<Class<*>>(service)
val invocationHandler = createInvocationHandler(service, client, resultDeserializer, logger)
@Suppress("UNCHECKED_CAST")
@andhikayuana
andhikayuana / working_effectively_with_legacy_code.md
Created November 30, 2023 08:09 — forked from jonnyjava/working_effectively_with_legacy_code.md
Working effectively with legacy code summary

WORKING EFFECTIVELY WITH LEGACY CODE

To me, legacy code is simply code without tests. I’ve gotten some grief for this definition. What do tests have to do with whether code is bad? To me, the answer is straightforward, and it is a point that I elaborate throughout the book: Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse.

Chapter 1 Changing Software

Four Reasons to Change Software: For simplicity’s sake, let’s look at four primary reasons to change software.

import org.junit.Test;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Scheduler;
import rx.functions.Func1;
import rx.observers.AssertableSubscriber;
import rx.schedulers.TestScheduler;