Skip to content

Instantly share code, notes, and snippets.

View addeeandra's full-sized avatar
🐣
Is it egg, chicken, or both?

Aditya Chandra addeeandra

🐣
Is it egg, chicken, or both?
View GitHub Profile
@addeeandra
addeeandra / VerifiableTrait.php
Created September 18, 2023 09:43
Using OwenIt\Auditing, this trait extends the functionality to verify and undo, also to get unverified fields.
<?php
namespace App\Concerns\Audit;
use JetBrains\PhpStorm\ArrayShape;
/**
* @method \Illuminate\Database\Eloquent\Relations\MorphMany<OwenIt\Auditing\Contracts\Audit> audits()
*
* @method save()
# create new user
useradd -m dentro
passwd dentro
# add user to sudo-group
usermod -aG sudo dentro
# move to new user sh
su dentro
cd
# make sure to run `update` and `upgrade` before proceeding, and if there is kernel update, please reboot before continue
#!/bin/bash
sudo apt get nala cargo
sudo nala install linux-firmware linux-generic ronn build-essential pkg-config
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# make sure to run `update` and `upgrade` before proceeding, and if there is kernel update, please reboot before continue
#!/bin/bash
sudo nala install linux-firmware linux-generic ronn build-essential pkg-config
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
mkdir -p ~/downloads
@addeeandra
addeeandra / .env
Last active June 14, 2022 09:44
Docker Compose for Laravel Project
DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=my_db
DB_USERNAME=my_user
DB_PASSWORD=my_pass@123
DOCKER_PORT=8888
@addeeandra
addeeandra / DashboardUI.kt
Created March 13, 2022 10:49
ViewStubBehavior Usage
// might be called from Activity.onCreate or Fragment.onViewCreated
override fun setupViews() {
// setup stub behavior on sales
ViewStubBehavior.setup(
viewBinding.flSales,
viewBinding.stubSales,
viewBinding.scrollContainer
) { _, view ->
val stubBinding = DataBindingUtil.bind<ViewSectionSalesBinding>(view)
stubBinding?.lifecycleOwner = this
@addeeandra
addeeandra / ViewStubBehavior.kt
Last active March 13, 2022 10:26
Reusable ViewStubBehavior within Scrolling Layout.
import android.view.ViewStub
import android.widget.FrameLayout
import androidx.databinding.ViewStubProxy
object ViewStubBehavior {
fun setup(
stubWrapper: FrameLayout,
stubProxy: ViewStubProxy,
scrollContainer: FrameLayout,
@addeeandra
addeeandra / Debounce.kt
Created January 27, 2021 02:24
Debounce wrapper for LiveData observer
class Debounce<T>(
val data: LiveData<T>,
delay: Long = 500L,
call: (data: T) -> Unit
) : CoroutineScope {
override val coroutineContext: CoroutineContext = Dispatchers.Main
private var debounce = delay // ms
private var job: Job? = null
@addeeandra
addeeandra / PartRequest.kt
Created November 18, 2020 17:16
A snippet code to build MultipartBody.Part easily.
object PartRequest {
@JvmStatic
fun buildFileBody(file: File): RequestBody {
return RequestBody.create(MediaType.parse("image/jpg"), file)
}
@JvmStatic
fun buildTextBody(value: String): RequestBody {
return RequestBody.create(MediaType.parse("text/plain"), value)
@addeeandra
addeeandra / dockerinfo.sh
Created July 31, 2020 17:56
Linux utility stuffs.
#/bin/bash
GREEN='\033[1;32m'
WHITE='\033[1;38m'
NC='\033[0m'
# Getting common docker information
# - Container(s) information
# - Default Network (bridge) information
# - Available Images(s) information