Usefull ADB Commands

adb devices

adb reboot recovery

adb reboot-bootloader

adb push [source] [destination]

adb pull

adb install [source.apk]

adb install -r [source.apk] // installing while keeping the app's data, as you would on the market or with an APK (It means update )

fastboot oem unlock

fastboot devices

fastboot reboot

fastboot flash recovery

adb sideload update.zip

References
http://lifehacker.com/the-most-useful-things-you-can-do-with-adb-and-fastboot-1590337225
https://tektab.com/2015/10/31/android-bootloaderfastboot-mode-and-recovery-mode-explained/
https://stackoverflow.com/questions/8962226/testing-an-adb-update-versus-install

Java Enums

Enum Example

public enum Level {
    HIGH,
    MEDIUM,
    LOW
}

Enums in if Statements

Level level = ...  //assign some Level constant to it

if( level == Level.HIGH) {

} else if( level == Level.MEDIUM) {

} else if( level == Level.LOW) {

}

Enum Iteration

for (Level level : Level.values()) {
    System.out.println(level);
}

Enum Fields

public enum Level {
    HIGH  (3),  //calls constructor with value 3
    MEDIUM(2),  //calls constructor with value 2
    LOW   (1)   //calls constructor with value 1
    ; // semicolon needed when fields / methods follow


    private final int levelCode;

    private Level(int levelCode) {
        this.levelCode = levelCode;
    }
}

Enum Methods

public enum Level {
    HIGH  (3),  //calls constructor with value 3
    MEDIUM(2),  //calls constructor with value 2
    LOW   (1)   //calls constructor with value 1
    ; // semicolon needed when fields / methods follow


    private final int levelCode;

    Level(int levelCode) {
        this.levelCode = levelCode;
    }
    
    public int getLevelCode() {
        return this.levelCode;
    }
    
}

References
http://tutorials.jenkov.com/java/enums.html
https://www.mkyong.com/java/java-enum-example/

Spring Data MongoDB – Indexes, Annotations and Converters

Indexed
This annotation marks the field as indexed in MongoDB

@QueryEntity
@Document
public class User {
    @Indexed
    private String name;
     
    ... 
}

Compound Indexes
MongoDB supports compound indexes, where a single index structure holds references to multiple fields.

@QueryEntity
@Document
@CompoundIndexes({
    @CompoundIndex(name = "email_age", def = "{'email.id' : 1, 'age': 1}")
})
public class User {
    //
}

Transient
As you would expect, this simple annotation excludes the field from being persisted in the database.

public class User {
     
    @Transient
    private Integer yearOfBirth;
    // standard getter and setter
 
}

Field
@Field indicates the key to be used for the field in the JSON document

@Field("email")
private EmailAddress emailAddress;

References
http://www.baeldung.com/spring-data-mongodb-index-annotations-converter

Gradle Task

task cleanAll {
    group = 'minify'
    doFirst {
        tasks.cleanCSS.execute()
        tasks.cleanJS.execute()
    }
}
task cleanCSS {
    group = 'minify'
    doLast {
        String basePath = 'src/main/resources/static/stylesheets/site';
        FileTree tree = project.fileTree(dir: basePath);
        tree.include "**/*.css"
        tree.exclude "**/*.scss"
        tree.exclude "**/*.css.map"

        tree.visit { FileVisitDetails element ->
            if (!element.isDirectory()) {
                element.file.delete()
            }
        }
    }
}
task cleanJS {
    group = 'minify'
    doLast {
        String basePath = 'src/main/resources/static/javascripts/site';
        FileTree tree = project.fileTree(dir: basePath);
        tree.include "**/*.min.js"
        tree.exclude "**/*.js.map"
        tree.exclude "**/*.ts"
        tree.exclude "**/*.d.ts"

        tree.visit { FileVisitDetails element ->
            if (!element.isDirectory()) {
                element.file.delete()
            }
        }
    }
}
task sass {
    group = 'minify'
    doLast {
        String basePath = 'src/main/resources/static/stylesheets/site';
        FileTree tree = project.fileTree(dir: basePath);
        tree.include "**/*.scss"
        tree.exclude "**/*.css"
        tree.exclude "**/*.css.map"

        tree.visit { FileVisitDetails element ->
            if (!element.isDirectory()) {
                String filePath = basePath + "/" + element.getPath();

                int pos = filePath.lastIndexOf(".");
                String newFilePath = "";

                if (pos > 0) {
                    newFilePath = filePath.substring(0, pos) + ".css";
                }

                if (project.file(newFilePath).exists()) {
                    project.file(newFilePath).delete();
                }


                String cmd = String.format("node-sass $filePath $newFilePath");
                java.lang.Runtime.getRuntime().exec(cmd);
            }
        }
    }
}
task csso {
    group = 'minify'
    doLast {
        String basePath = 'src/main/resources/static/stylesheets/site';
        FileTree tree = project.fileTree(dir: basePath);
        tree.include "**/*.css"
        tree.exclude "**/*.min.css"
        tree.exclude "**/*.css.map"
        tree.exclude "**/*.scss"

        tree.visit { FileVisitDetails element ->
            if (!element.isDirectory()) {
                String filePath = basePath + "/" + element.getPath();

                int pos = filePath.lastIndexOf(".");
                String newFilePath = "";

                if (pos > 0) {
                    newFilePath = filePath.substring(0, pos) + ".min.css";
                }

                String cmd = String.format("csso -i $filePath -o $newFilePath");
                java.lang.Runtime.getRuntime().exec(cmd);
            }
        }
    }
}
task uglify {
    group = 'minify'
    doLast {
        String basePath = 'src/main/resources/static/javascripts/site';
        FileTree tree = project.fileTree(dir: basePath);
        tree.include "**/*.js"
        tree.exclude "**/*.min.js"
        tree.exclude "**/*.js.map"
        tree.exclude "**/*.ts"
        tree.exclude "**/*.d.ts"

        tree.visit { FileVisitDetails element ->
            if (!element.isDirectory()) {
                String filePath = basePath + "/" + element.getPath();

                int pos = filePath.lastIndexOf(".");
                String newFilePath = "";

                if (pos > 0) {
                    newFilePath = filePath.substring(0, pos) + ".min.js";
                }

                String cmd = String.format("uglifyjs $filePath -o $newFilePath");
                java.lang.Runtime.getRuntime().exec(cmd);
            }
        }
    }
}
sass.mustRunAfter cleanCSS
csso.mustRunAfter sass
uglify.mustRunAfter cleanJS
task minify{
    group = 'minify'
    doFirst{
        tasks.cleanCSS.execute()
        tasks.cleanJS.execute()
    }
    doLast{
        tasks.sass.execute()
        tasks.csso.execute()
        tasks.uglify.execute()
    }
}

References
https://docs.gradle.org/current/userguide/working_with_files.html
https://docs.gradle.org/current/userguide/tutorial_using_tasks.html
https://docs.gradle.org/current/userguide/custom_tasks.html
https://docs.gradle.org/current/userguide/more_about_tasks.html