Skip to content

Instantly share code, notes, and snippets.

View mochadwi's full-sized avatar
💭
I may be slow to respond.

Mochamad Iqbal Dwi Cahyo mochadwi

💭
I may be slow to respond.
View GitHub Profile
@cerebrl
cerebrl / rewriting-git-history.md
Last active August 13, 2025 02:34
Understand how rewriting history with `git amend` and `git rebase` can be crucial in keeping your Git logs clean and simple, while avoiding some dangerous consequences.

Rewriting Git History

Say you have a code base that you just created and you have two commits locally:

commit a
commit b

This is your “version history”. You then push these commits to your remote. Now you have two repos with the same history:

* What went wrong:
Execution failed for task ':app:checkDebugAndroidTestDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class org.apache.maven.artifact.Artifact found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.ArtifactStatus found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.ArtifactUtils found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.DefaultArtifact found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1
@firyalff
firyalff / sample issue report.md
Created November 7, 2019 04:39
Sample Issue

Issue General Information

This is a sample issue to be used as a template for every bugs or even suggestion for improvement. Issue raised in each repository better be following this sample issue structure. The first section is general info of the issue while this paragraph also works as an general info example. Every problem occurred in development cycle MUST be written as repository issue to ease problem follow-ups.

Step to Reproduce

  1. In this section you need to describe the steps to reproduce the issue
  2. The steps written needs to be as detailed and complete as possible
  3. Since this will help devs to trace and find the solution
@abd3lraouf
abd3lraouf / Readme.md
Last active November 27, 2019 08:22
AndroidX manual Migration script

Procedure

  1. Open terminal from android studio or navigate to the projet's root directory

Long link

  1. curl -s -L https://gist.githubusercontent.com/AbdElraoufSabri/907163eecbb87e7ca033d01004623c05/raw/executor.sh | bash

short link

  1. curl -s -L https://git.io/JevZ4 | bash

short link #2

@felipefpx
felipefpx / coverage.sh
Created September 1, 2019 10:29
Jacoco Merged Report for Multimodule Android with Kotlin DSL
#!/bin/bash
clear
./gradlew clean mergedJacocoReport
./gradlew jacocoFullReport
REPORT_PATH="file://$(pwd)/build/reports/jacoco/jacocoFullReport/html/index.html"
echo ${REPORT_PATH} | pbcopy
echo "Report available at:"
echo ${REPORT_PATH}
echo "Report file path copied to clipboard. You can paste it in your favorite browser. :)"
@gsavvid
gsavvid / publishMavenBintray.gradle
Last active November 2, 2022 12:48 — forked from Robyer/maven-publish-helper-usage.gradle
Gradle script for publishing Android Kotlin libraries to a Bintray repository using maven-publish plugin. With dependencies (also handling transitive: false and custom exclude rules), including sources and javadoc.
/**
* Publish Android Kotlin Library Helper
*
* This Gradle script is based on https://gist.github.com/Robyer/a6578e60127418b380ca133a1291f017.
* The difference is that:
* 1. It uses Dokka for generating Kotlin Javadoc.
* 2. It uses Jfrog's plugin for publishing to Bintray. If you don't want to publish to Bintray, simply remove all the Bintray-related code.
*
* NOTE: You need to add Dokka and Bintray to your classpath for the two plugins to work.
* Update the buildscript in your project's build.gradle with the following:
@loganj
loganj / script.sh
Last active April 3, 2024 03:45 — forked from dlew/script.sh
Simple AndroidX Migration Script
#!/usr/bin/env bash
# Original by Dan Lew
#
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
@elizarov
elizarov / DeepRecursiveFunction.kt
Last active March 25, 2024 00:40
Defines recursive function that keeps its stack on the heap (productized version)
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
/**
* Defines deep recursive function that keeps its stack on the heap,
* which allows very deep recursive computations that do not use the actual call stack.
* To initiate a call to this deep recursive function use its [invoke] function.
* As a rule of thumb, it should be used if recursion goes deeper than a thousand calls.
*
* The [DeepRecursiveFunction] takes one parameter of type [T] and returns a result of type [R].
fun Any?.toHashMap(): HashMap<String, RequestBody> {
val map = HashMap<String, RequestBody>()
if(this == null){
return map
}
for (field in this.javaClass.declaredFields) {
val temp = field.isAccessible
field.isAccessible = true
@jeffypooo
jeffypooo / max-heap-example.kt
Created March 31, 2019 03:18
Kotlin max heap example
data class Worker(
val quality: Int,
val wage: Int,
val ratio: Double = wage.toDouble() / quality.toDouble()
)
class MaxHeap(private var capacity: Int = 32) {
private var array = arrayOfNulls<Worker>(capacity)
var size = 0