Skip to content

Instantly share code, notes, and snippets.

@jprinet
jprinet / process-scans.sh
Last active May 15, 2024 19:07
Get list of Github repositories in build scans
#!/bin/bash
# init parameters
readonly geUrl=$1
readonly bearerToken=$2
readonly daysAgo=$3
# init global vars
readonly maxBuildsPerBatch=100
readonly recoveryFile="$0.out.build-scan-id"
@ZacSweers
ZacSweers / Notes.md
Last active January 31, 2023 00:24
MergeFileTask Patch

The Problem

While doing some remote build cache fidelity testing in #66841, I found that our lint analysis tasks were consistently getting cache misses due to an esoteric intermediate proguard file contents change.

After a little digging, I found these files were generated by AGP as a "merged" file of all that project's generated proguard files. This was most notable in projects using Moshi, which generates proguard rules on the fly.

My hunch was that these files were being merged with non-deterministic order, as I couldn't find anything that ensured ordering and this input was purely a file contents check (so the same rules in different order would still constitute a miss).

I was able to verify this was the case via snagging merged proguard.txt files via github actions artifact uploads.

I filed this issue for it here: issuetracker.google.com/issues/266403349 (note it's been made private for some reason).

@jprinet
jprinet / capture.kts
Last active July 22, 2022 14:21
Capture Task inputs size
tasks.withType<JavaCompile>().configureEach {
doLast {
this.inputs.files.map { it ->
if(it.isFile) {
FileSize(it.length(), it.path)
} else {
FileSize(0, "DIR - " + it.path)
}
}.sortedBy {
it.size
@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))
/**
* 1) Change agpVersion
* 2) Run './gradlew dumpSources'
* 3) Check changeset into source control
*/
def agpVersion = 'UPDATE_THIS'
repositories {
google()
jcenter()
@pablisco
pablisco / Logger.kt
Last active May 17, 2018 10:35
Fluent Logging with Kotlin
inline fun <A> A.logWith(logger: Logger, block: Logger.(A) -> Unit) : A =
this.also { logger.block(it) }
// With interface injection
interface HasLog {
val log: Logger
fun <A> A.log(block: Logger.(A) -> Unit) : A =
logWith(logger, block)
}
/**
* Created by jjst on 21/03/16.
*/
object Floors {
def main(args: Array[String]): Unit = {
Console.println(floorNumber1("())"))
Console.println(floorNumber2("())"))
Console.println(floorNumber2(""))
}
@alxsimo
alxsimo / ResourceHelper.java
Created March 12, 2016 14:51
[Android] Load resources from unit test
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.net.URL;
public class ResourceHelper {
public String convertFileToString(File file) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder sb = new StringBuilder();
import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
import android.widget.AbsListView;
import com.jakewharton.rxbinding.view.ViewEvent;
public final class ListViewScrollEvent extends ViewEvent<AbsListView> {
@CheckResult
@NonNull
@cb372
cb372 / jargon.md
Last active May 14, 2024 03:45
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.