Friday, January 26, 2018

Linux Commands in a nutshell

Go back to the previous directory in shell
cd -
It goes back to the previous directory.
cd $OLDPWD
This can be also used in shell scripts.

Difference between dependencies within buildscript closure and core?

I want to give you clear conception. For this reason, I am attaching build.grade snapshot code for better understanding.
buildscript {
    repositories {
        maven { url("https://plugins.gradle.org/m2/") }
    }

    dependencies {
        classpath 'net.saliman:gradle-cobertura-plugin:2.3.2'
        classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release'
    }
}

repositories{
    mavenLocal()
    maven { url("https://plugins.gradle.org/m2/") }
    maven { url "https://repo.spring.io/snapshot" }
}

dependencies {
        //Groovy
        compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.3.10'

        //Spock Test
        compile group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.3'

        //Test
        testCompile group: 'junit', name: 'junit', version: '4.10'
        testCompile group: 'org.testng', name: 'testng', version: '6.8.5'
}
So, First I want to clarify in single word that
i) buildscript dependencies jar file will be downloaded from buildscript repositories.[Project external dependency]
ii) root level dependencies jar file will be downloaded from root level repositories.[For project dependency]
Here,
The “buildscript” block only controls dependencies for the buildscript process itself, not for the application code. As various gradle plugin like gradle-cobertura-plugingradle-lint-pluginare found from buildscript repos. Those plugins would not be referenced as dependencies for the application code.
But for project compilation and test running jar files like groovy all jar, junit and testng jarwill be found from root level repositories.
And another thingmaven { url("https://plugins.gradle.org/m2/") } portion can be used in both blocks. Because they are used for different dependencies.

EUC-JP conversion in PHP

Friday, January 19, 2018

gradle lint plugin to remove unused dependencies

In parent project,  Add the following code in build.gradle or init.gradle

buildscript {
repositories { maven { url("https://plugins.gradle.org/m2/") } }
dependencies {
classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release'
}
}
plugins {
id 'java'
id 'groovy'
id 'maven'
id 'jacoco'
id 'application'
id 'nebula.lint' version '7.4.0'
}
allprojects {
  apply plugin: 'nebula.lint'
  gradleLint.rules = ['unused-dependency']
}

Then run the following command:

gradle lintGradle
gradle fixGradleLint
gradle compileJava fixGradleLint


  1. https://github.com/nebula-plugins/gradle-lint-plugin/issues/38
  2. https://stackoverflow.com/a/25525390
  3. https://discuss.gradle.org/t/task-run-not-found-in-root-project/12130/3
  4. https://github.com/wfhartford/gradle-dependency-analyze
  5. https://www.youtube.com/watch?v=0ZS_bqD1dkg

Sunday, January 14, 2018

How to write high quality code?


Prohibited in coding(Haram Programming). Check if you are doing any of these.

•Writing a large function with even larger classes: Keep you functions below 30 line and you class below 200 lines. •Storing password in plain text in database: Always hash with a salt. Don't use MD5, it's compromised. •Returning a list from the server without paging: Use a page number and page size parameter. •Sorting or searching on the client side: Otherwise its sorts the current page only. •Querying more columns than needed: Slows down the query and increase data transfer to the client. •Not Indexing the Database: Makes your query super slow. •Not logging on Server side code: Without log when you code is deployed you will have no way to know what went wrong. Use a logging framework. •Not using dependency injection: Ensures decoupled maintainable architecture. •Not using source control: You cannot collaborate, leaves you at the mercy of your HDD. •Not localizing UI text: Makes your life hell when the customer says he needs it in German.

Collected from Linkedin post of Topu Newaz Sir: