Skip to content

Instantly share code, notes, and snippets.

View nikialeksey's full-sized avatar
🏠
Working from home

Alexey Nikitin nikialeksey

🏠
Working from home
View GitHub Profile
@nikialeksey
nikialeksey / ConstructorsInGson.kt
Created September 23, 2017 14:43
Kotlin and Gson bug
import com.google.gson.Gson
enum class T {A, B}
open class A(val a: T)
class B(val b: T) : A(T.A)
fun main(args: Array<String>) {
val b = Gson().fromJson("{\"b\":\"B\"}", B::class.java)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nikialeksey.moxybug"
minSdkVersion 20
targetSdkVersion 27
}
buildTypes {
@nikialeksey
nikialeksey / dependency-report.gradle
Created June 28, 2018 03:44
Gradle: multi-project dependency graph (supports depth > 2, supports gradle 4.4+)
// Inspired by https://gist.github.com/tzachz/419478fc8b009e953f5e5dc39f3f3a2a
// Task creates a .dot file with all inter-module dependencies
// Supports any depth of nested modules
task moduleDependencyReport {
doLast {
def file = new File("project-dependencies.dot")
file.delete()
file << "strict digraph {\n"
file << "splines=ortho\n"
@nikialeksey
nikialeksey / StaticAnalysis.kt
Last active October 9, 2018 10:37
Run detekt in unit test
package app.package.name
import io.gitlab.arturbosch.detekt.api.Finding
import io.gitlab.arturbosch.detekt.api.YamlConfig
import io.gitlab.arturbosch.detekt.core.DetektFacade
import io.gitlab.arturbosch.detekt.core.ProcessingSettings
import io.gitlab.arturbosch.detekt.rules.providers.*
import org.hamcrest.core.IsEqual
import org.junit.Assert
import org.junit.Test
@nikialeksey
nikialeksey / DictionaryTest.kt
Last active November 2, 2018 18:27
Android localization unit-test
package com.example
import com.atlascopco.hunspell.Hunspell
import org.hamcrest.core.IsEqual
import org.junit.Assert
import org.junit.Test
import java.io.BufferedReader
import java.io.File
import java.io.FileReader
import java.util.*
@nikialeksey
nikialeksey / CommitVerifier.kt
Created December 27, 2018 18:25
Fail if the commit does not have CHANGELOG tag
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
import org.hamcrest.core.IsEqual
import org.junit.Assert
import org.junit.Test
import java.io.File
import java.util.*
class CommitVerifier {
@Test
fun changelogPresents() {
@nikialeksey
nikialeksey / WtfCreator.java
Last active December 14, 2022 07:05
Joshua Bloch Wtf.java break-in
import org.apache.commons.math3.analysis.interpolation.NevilleInterpolator;
public class WtfCreator {
public static void main(String[] args) {
var text = "Hello, world!\n";
double[] x = new double[text.length() + 1];
double[] y = new double[text.length() + 1];
for(var i = 0; i < text.length(); i++) {
x[i] = i;