Skip to content

Instantly share code, notes, and snippets.

View jboxx's full-sized avatar
🇮🇩
Shut up! I am PRO

Rifqi Fardi Pradhana jboxx

🇮🇩
Shut up! I am PRO
View GitHub Profile
@jboxx
jboxx / ConnectionHelper.kt
Created August 19, 2025 18:48
Observe Connection Network on Android
import android.annotation.SuppressLint
import android.content.Context
import android.net.ConnectivityManager
import android.net.LinkProperties
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import android.net.wifi.WifiManager
import android.os.Build
import android.util.Log
@jboxx
jboxx / EndlessScrollListener.kt
Last active April 27, 2022 05:26
Setup Endless Scroll Listener
private fun setupNestedScrollViewEndlessScroll() {
nsvUserDetail.setOnScrollChangeListener( NestedScrollView.OnScrollChangeListener { v, _, scrollY, _, oldScrollY ->
val lastView = v.getChildAt(v.childCount - 1)
if (lastView != null && (scrollY >= (lastView.measuredHeight - v.measuredHeight)) && scrollY > oldScrollY) {
loadMoreRepos()
}
})
ViewCompat.setNestedScrollingEnabled(rvList, false)
}
@jboxx
jboxx / android_setup.md
Last active June 23, 2023 06:36
Mac Instalation Homebrew

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install ZSH

brew install zsh

Install Oh-My-Zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

@jboxx
jboxx / EventTimer.kt
Created July 28, 2021 08:32
This class is for count elapsed time multiple events
import java.util.*
import java.util.concurrent.TimeUnit
class EventTimer private constructor() {
private val events = mutableMapOf<String, Long>()
fun start(eventName: String) {
val writeTime = System.nanoTime()
synchronized(events) {
@jboxx
jboxx / Sleep.myscript
Created October 10, 2020 13:55
Sleep.myscript a script to enable sleep mode once try to close lid
## Note: This file is optional but good to have in case you somehow get stuck in No Sleep mode.
# Starting main script
echo "Starting script...";
echo ""
echo "Enter password to update sleep settings: "
sudo echo "Reverting any still-un-revered settings and going to sleep..."
sudo pmset -a disablesleep 0
sudo pmset sleepnow
echo ""
@jboxx
jboxx / DontSleep.myscript
Last active October 10, 2020 13:54
DontSleep.myscript script to disable sleep once enter the Unpowered Clamshell Mode
# Starting main script
echo "Starting script...";
echo ""
echo "Enter password to update sleep settings: "
sudo echo "Disabling sleep..."
# Creating helper process
echo "# This is a helper script. Do not run manually." > ~/Desktop/PauseSleep/DontSleepHelper.sh
echo "sudo pmset -a disablesleep 1" >> ~/Desktop/PauseSleep/DontSleepHelper.sh
echo "rm -f ~/Desktop/PauseSleep/DontSleepHelper.sh" >> ~/Desktop/PauseSleep/DontSleepHelper.sh
@jboxx
jboxx / Main.java
Created November 6, 2019 07:23
Java Reflection Playground
package io.jboxx;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Main {
public static class Builder {
@jboxx
jboxx / weather-status.sh
Created August 28, 2019 04:43
To get weather status per city
#!/bin/bash
### How to use it? ###
## just run it like common bash script "sh weather-status.sh -c={CITY_NAME}" | "sh weather-status.sh --city={CITY_NAME}"
for i in "$@"
do
case $i in
-c=*|--city=*)
CITY="${i#*=}"
@jboxx
jboxx / build.gradle
Created August 15, 2019 08:36
change the limit that is printed to the console in android studio
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}
}
@jboxx
jboxx / View.java
Last active March 20, 2019 06:59
View OnClick and OnLongClick interface listener this approach explaining how Interface Segregation should be looks like
public interface GoodViewListener {
/**
* Interface definition for a callback to be invoked when a view is clicked.
*/
public interface OnClickListener {
/**
* Called when a view has been clicked.
*
* @param v The view that was clicked.
*/