Skip to content

Instantly share code, notes, and snippets.


Zac Sweers ZacSweers

View GitHub Profile


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.
ZacSweers / BlurrinessDetection.kt
Last active Oct 12, 2020
Demo implementation of client-side image blurriness detection on Android using renderscript.
View BlurrinessDetection.kt
* 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
* Unless required by applicable law or agreed to in writing, software
ZacSweers /
Last active Oct 7, 2020
Sample bug report for Moshi
package test;
import static;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import org.junit.Test;
public class MoshiBugReport {
ZacSweers /
Last active Sep 4, 2020
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 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

ZacSweers / 1-Before.txt
Last active Jun 21, 2020
Dagger new error messages output comparison
View 1-Before.txt
/Users/zsweers/dev/android/personal/CatchUp/app/build/generated/source/kapt/debug/io/sweers/catchup/app/ error: [Dagger/DuplicateBindings] androidx.activity.ComponentActivity is bound multiple times:
public abstract static class ApplicationC implements ApplicationComponent,
@org.jetbrains.annotations.NotNull @io.sweers.catchup.injection.scopes.PerActivity @Binds androidx.activity.ComponentActivity io.sweers.catchup.injection.ActivityModule.provideComponentActivity(T)
@org.jetbrains.annotations.NotNull @io.sweers.catchup.injection.scopes.PerActivity @Binds androidx.activity.ComponentActivity io.sweers.catchup.ui.about.AboutActivity.Module.provideComponentActivity(io.sweers.catchup.ui.about.AboutActivity)
@org.jetbrains.annotations.NotNull @io.sweers.catchup.injection.scopes.PerActivity @Binds androidx.activity.ComponentActivity io.sweers.catchup.ui.activity.MainActivity.ServiceIntegrationModule.provideComponentActivity(io
ZacSweers / ExponentialBackoff
Last active Apr 14, 2020 — forked from jerrellmardis/ExponentialBackoff
View ExponentialBackoff
// retries up to 3 times while exponentially backing off with each retry
.retryWhen(errors ->
Observable.range(1, MAX_RETRIES), (n, i) -> i
retryCount -> Observable.timer((long) Math.pow(4, retryCount), TimeUnit.SECONDS)
ZacSweers / WeakMutableSet.kt
Created Oct 25, 2019
A weak Set & MutableSet implementation in Kotlin.
View WeakMutableSet.kt
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
* You can obtain a copy of the license at
* glassfish/bootstrap/legal/CDDLv1.0.txt or
* See the License for the specific language governing
View Complex.kt
@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
View InlineMask.kt
// Code generated by moshi-kotlin-codegen. Do not edit.
package com.squareup.moshi.kotlin.codgen
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.squareup.moshi.internal.Util
import java.lang.NullPointerException
You can’t perform that action at this time.