Skip to content

Instantly share code, notes, and snippets.

View addeeandra's full-sized avatar
🐣
Nothing happening

Aditya Chandra addeeandra

🐣
Nothing happening
View GitHub Profile
@addeeandra
addeeandra / curl-check.sh
Last active November 6, 2024 10:28
A snippet of bash script to check connectivity via `ping` and `curl` command
#!/bin/bash
IP_VLAN=10.22.2.1
if curl -s $IP_VLAN > /dev/null; then
echo "Access to $IP_VLAN (vlan) is open."
else
echo "Access to $IP_VLAN (vlan) is not available."
fi
@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.example
Last active July 27, 2024 15:59
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)