Skip to content

Instantly share code, notes, and snippets.

View whitipet's full-sized avatar
👨‍💻
Code Every Day

Petro Bilyi whitipet

👨‍💻
Code Every Day
View GitHub Profile
@whitipet
whitipet / PlayerPositionTracker.kt
Created June 6, 2023 20:48
Position tracker for android media3 Player
private const val MIN_UPDATE_INTERVAL_MS: Long = 200
private const val MAX_UPDATE_INTERVAL_MS: Long = 1000
class PlayerPositionTracker {
private val handlerUpdatePosition = Handler()
private val runnableUpdatePosition = Runnable { updatePosition() }
var player: Player? = null
set(value) {
@whitipet
whitipet / adb_connect_to_hotspot.sh
Created May 24, 2023 18:18
Connect adb to the device that acts as a hotspot
adb connect $(route -n get default | grep gateway | awk '{ print $2 }')
@whitipet
whitipet / JSON.vm
Last active June 21, 2024 20:43
IntelliJ IDEA JSON toString() template
public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
return "{\"$classname\":{"
#foreach( $member in $members )
#if ( $i == 0 )
+ "##
#else
+ ", ##
#end
@whitipet
whitipet / PossibleSums.java
Created January 22, 2017 16:08
Get all possible sums with indexes from array
import java.util.ArrayList;
import java.util.List;
public class PossibleSums {
public static List<Sum> getSumsList(final int[] numbersArray) {
final List<Sum> returnSumsList = new ArrayList<>();
final int numberOfSums = (int) Math.pow(2, numbersArray.length);
for (int i = 1; i < numberOfSums; i++) {
final Sum sum = new Sum();