Skip to content

Instantly share code, notes, and snippets.

@jrodbx
jrodbx / cashapp_gradle_enterprise.gradle
Last active October 7, 2023 02:29
Example Gradle Enterprise config
import groovy.json.JsonSlurper
import static java.nio.charset.Charset.defaultCharset
import static java.util.concurrent.TimeUnit.SECONDS
// Captures build and environment data and stores it in build scans via custom tags, links,
// and values, for one-off and trend analyses.
gradleEnterprise {
buildScan {
@ghale
ghale / captureFingerprints.gradle
Last active July 19, 2023 11:13
Capture task classpath fingerprints
def fingerprinter = services.get(org.gradle.internal.fingerprint.classpath.ClasspathFingerprinter)
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { task ->
doFirst {
ClassLoader classLoader = task.getClass().classLoader
while (classLoader instanceof URLClassLoader) {
def fingerprints = [] as Set
def allFiles = [] as Set
classLoader.getURLs().each {
fingerprints.add(["${task.path}:${file(it.file).name}", "${fingerprinter.fingerprint(files(it.file)).hash}"])
allFiles.add(file(it.file))
@runningcode
runningcode / build.gradle
Created July 29, 2020 17:41
Print out Android Studio Injected properties
project.properties.forEach { key, value ->
if (key.startsWith('android.injected')) {
println("$key:$value")
}
}
@gcollic
gcollic / git_for_intellij.sh
Last active February 15, 2023 10:03
Replace the path to git by the path of this file in order to stop IntelliJ from messing with your staging area (no config for rename & co).
#!/bin/bash
inner() {
local cmd="$@"
local REGEX="(^|log.showSignature=false )(add|rm|mv) "
if [[ $cmd =~ $REGEX ]]; then
echo 'Stopping IntelliJ from being a not well-behaved git client. See IDEA-194592, IDEA-63391, IDEA-176961, ...' >&2
return 1
fi
git "$@"
}
@writtmeyer
writtmeyer / GsonBuilderForRenamingWitoutUsingGsonAnnotations
Last active February 16, 2019 22:24
If you want to keep your domain objects free from GSON annotations, this is a possible way to do this.
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.setFieldNamingStrategy(new FieldNamingStrategy() {
@Override
public String translateName(Field f) {
if (f.getName().equals("stars")) {
return "stargazers_count";
} else if (f.getName().equals("repositories")) {
return "items";
} else {