Skip to content

Instantly share code, notes, and snippets.

View dsvoronin's full-sized avatar

Dmitriy Voronin dsvoronin

  • 22:58 (UTC +01:00)
View GitHub Profile
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@chrisbanes
chrisbanes / code.kt
Last active August 10, 2023 10:46
Night Mode inflater
/*
* Copyright 2017 Google, 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
*
* Unless required by applicable law or agreed to in writing, software
@sideffect0
sideffect0 / build.gradle
Last active April 5, 2017 05:31
load gradle build variables or properties from properties file or system environment
apply from: "envutils.gradle"
// loading to data map
def data = loadFromEnvOrProp()
buildTypes {
release {
minifyEnabled false
buildConfigField "String", "API_URL", data["api.url"]
@balachandarlinks
balachandarlinks / Dockerfile
Last active November 27, 2020 14:20
Dockerfile for https://github.com/gojuno/mainframer remote android build system.
FROM ubuntu:16.04
MAINTAINER Balachandar KM "balachandarlinks@gmail.com"
# Install java7
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:webupd8team/java && \
(echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections) && \
apt-get update && \
@wojteklu
wojteklu / clean_code.md
Last active May 5, 2024 21:39
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@halfvector
halfvector / jacocoTestReport-build.gradle
Created September 29, 2016 16:49
jacocoTestReport for unit + instrumentation test code coverage for Android
/**
* This JacocoTestReport task merges local Unit Tests and emulator/device Instrumentation Tests into a single coverage report.
* Also ignores Dagger 2 generated code.
* Add this task to your Android app/build.gradle and run your test suites then execute this task.
* Coverage report will appear in app/build/reports/jacoco/jacocoTestReport/
* as standard xml compatible with codecov.io and human readable html
* dependsOn: ['testDebugUnitTest', 'connectedDebugAndroidTest']
*/
task jacocoTestReport(type: JacocoReport) {
group = "Reporting"
@satyadeepk
satyadeepk / gcloud_install.sh
Last active February 18, 2022 12:21
Jenkins Google Cloud SDK install with auth script
#Ref: https://github.com/circleci/android-cloud-test-lab/blob/master/circle.yml
export DIRECTORY="/var/jenkins_home/GoogleCloudSDK/google-cloud-sdk/bin"
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
cd /var/jenkins_home
wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.zip -O google-cloud-sdk.zip
unzip -o google-cloud-sdk.zip -d ./GoogleCloudSDK/
./GoogleCloudSDK/google-cloud-sdk/install.sh
@riggaroo
riggaroo / AndroidManifest.xml
Created April 13, 2016 17:31
Custom Android Espresso Test Runner - Unlocking a Device, Granting Permission to turn animations off, turning the Screen on.
<?xml version="1.0" encoding="utf-8"?>
<!-- Put this file in the "debug" folder so it only gets merged into debug builds -->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.bookdash.android">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Disable animations on debug builds so that the animations do not interfere with Espresso
@nsk-mironov
nsk-mironov / Reflection.kt
Created March 13, 2016 16:50
Kotlin Metadata
package com.github.vmironov
import kotlin.reflect.jvm.internal.impl.serialization.ClassData
import kotlin.reflect.jvm.internal.impl.serialization.Flags
import kotlin.reflect.jvm.internal.impl.serialization.ProtoBuf
import kotlin.reflect.jvm.internal.impl.serialization.jvm.JvmProtoBufUtil
data class Foo(val foo: String)
data class Bar(val bar: String)
@saxophone
saxophone / ResultTestActivity.java
Last active October 13, 2020 14:43
Use Android Espresso to test that your Activity finishes with the expected result.
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static org.hamcrest.MatcherAssert.assertThat;