Skip to content

Instantly share code, notes, and snippets.

View artem-zinnatullin's full-sized avatar
😞

Artem Zinnatullin artem-zinnatullin

😞
View GitHub Profile
@artem-zinnatullin
artem-zinnatullin / error_prone_buck.bzl
Created January 24, 2020 02:58
ErrorProne Integration with Buck
def apply_error_prone(**kwargs):
# Error Prone should be on by default in Bazel.
if IS_BAZEL:
return kwargs
has_java_files = False
for src in kwargs.get("srcs", []):
if src.endswith(".java"):
has_java_files = True
break
@artem-zinnatullin
artem-zinnatullin / detekt-config.yml
Created March 7, 2019 03:31
detekt-config.yml for Lyft Android Project
autoCorrect: true
failFast: false
test-pattern: # Configure exclusions for test sources
active: true
patterns: # Test file regexes
- '.*/test/.*'
- '.*Test.kt'
- '.*Spec.kt'
exclude-rule-sets:
@artem-zinnatullin
artem-zinnatullin / ValidationProcessor.java
Created September 20, 2018 18:04
Dagger1: allow @scope annotations on Dagger2 Components
/*
* Copyright (C) 2013 Google, Inc.
* Copyright (C) 2013 Square, Inc.
*
* 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
*

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.
@artem-zinnatullin
artem-zinnatullin / YourApp.java
Last active August 29, 2015 14:26
Fix for performance issue in RxJava 1.0.3+
// Issue: https://github.com/ReactiveX/RxJava/issues/3119
class YourApp extends Application {
static {
// I recommend you to put this code into static initialization block of Application class
// because Application class will be loaded before you will start doing some work via RxJava
// PLEASE add comment "remove fix from app class… when you'll switch to new version of RxJava"
// near to "compile 'io.reactivex:rxjava:1.0.13'" in your build.gradle
System.setProperty("rx.scheduler.jdk6.purge-force", "true");
@artem-zinnatullin
artem-zinnatullin / build.gradle
Last active December 1, 2020 17:54
Ignore particular buildType in Android Project
// Variant 1: For app or library project's build.gradle
android {
variantFilter {
if (it.buildType.name.equals('debug')) {
it.ignore = true
}
}
}
// Variant 2: For root build.gradle with applying only to library projects
@artem-zinnatullin
artem-zinnatullin / GradleWorkersPleaseStopTakingFocus.gradle
Created July 21, 2015 19:58
Prevent Gradle Workers from taking focus! #DevelopersLikeComfort
// You can place it in the root build.gradle
allprojects {
tasks.withType(JavaForkOptions) {
// Forked processes like GradleWorkerMain for tests won't steal focus!
jvmArgs '-Djava.awt.headless=true'
}
}
@artem-zinnatullin
artem-zinnatullin / build.gradle
Last active November 9, 2019 23:19
Android Unit tests logging configuration
android {
// ...
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
@artem-zinnatullin
artem-zinnatullin / HelloKotlinOnAndroid.kt
Created January 27, 2015 17:32
Hello Kotlin On Android
package nice.is.kotlin
import android.content.Context
import android.widget.Toast
class HelloKotlinOnAndroid {
public fun yo(context: Context, text: String) {
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
}
}
@artem-zinnatullin
artem-zinnatullin / build.gradle
Created January 27, 2015 17:18
App's build.gradle for Kotlin
apply plugin: 'kotlin-android'
android {
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
// NOTICE: dependencies are fixed for build stability
dependencies {