Skip to content

Instantly share code, notes, and snippets.

View ZacSweers's full-sized avatar

Zac Sweers ZacSweers

View GitHub Profile
@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).

@ZacSweers
ZacSweers / BlurrinessDetection.kt
Last active August 5, 2022 03:18
Demo implementation of client-side image blurriness detection on Android using renderscript.
/*
* Copyright (c) 2018. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ZacSweers
ZacSweers / crashcourse.md
Last active July 10, 2022 02:14
Python Reddit bot on Heroku

A crash course in setting up your Python Reddit bot on Heroku

You'll need to do the following:

  • You need to make your bot a python app. Do this by making another directory (can be the same name as the regular one) and put all your python code in that, and make an empty file called __init__.py in it as well. See how I structured mine if this isn't clear. In your base directory, create two files: "requirements.txt" and "runtime.txt". The requirements.txt file should be the output of pip freeze (you can run the command "pip freeze > requirements.txt"). If you're not using virtualenv, you'll need to go through after and delete all the lines with packages your code doesn't actually use. Check out mine to see what I mean. Runtime.txt just specifies with python version for heroku to use. Mine just has the line "python-2.7.4" in it. All of this will tell heroku to recognize your bot as a python app.

  • Make a heroku account and

@JsonClass(generateAdapter = true)
data class Foo<T>(
@Json(name = "barString") val bar: String,
val defaultValue: Int = 0,
val nullableString: String?,
val typeParam: T? = null,
val tList: List<T>
)
// Generated by Moshi Kotlin Code Gen
// Sample JSON
// { "bar": "hello world" }
// The Foo class
@JsonClass(generateAdapter = true)
data class Foo(
val bar: String
)
// Generated by Moshi Kotlin Code Gen
We couldn’t find that file to show.
@ZacSweers
ZacSweers / FacebookGroupLikesCounter.py
Last active July 26, 2021 13:27
Python code for getting like stats from posts in a Facebook group
from Queue import Queue # Threadsafe queue for threads to use
from collections import Counter # To count stuff for us
import datetime # Because datetime printing is hard
from pprint import pprint
import time # Should be obvious
import subprocess # Used to send notifications on mac
import sys # Get system info
import threading # Should be obvious
import json # Also obvious
@ZacSweers
ZacSweers / MoshiBugReport.java
Last active February 15, 2021 06:12
Sample bug report for Moshi
package test;
import static com.google.common.truth.Truth.assertThat;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import org.junit.Test;
import java.io.IOException;
public class MoshiBugReport {
@ZacSweers
ZacSweers / DiscussionGuidelines.md
Created November 20, 2017 07:04
Discussion guidelines

Guidelines

To keep the arguments and examples to the point there are few helpful rules:

  • No abstract examples/arguments. These cause the discussion to lose focus and make examples harder to follow. The example/argument must be traceable to a real-world problem - ___ is intended to solve real problems, not imaginary ones.
  • Examples must show the full complexity of the problem domain. Simplified examples trivialize the problems and the solutions intended to solve those simplified examples may not work for the complex problems.
  • Examples of problematic ___ code must be the “best way” of writing the code in ___ - if it can be improved then the improved version should be used instead.
  • Arguments must be straight to the point and as concise as possible.
  • Arguments should take the point of view of an average programmer - not the über-programmer who doesn’t make design mistakes.