Compare two beans with DiffBuilder

by GarciaPL on Thursday, 15 March 2018

Would you like to compare properties of two not related beans ? Are you tired of using Comparable interface from Java ? You might use class called DiffBuilder!

DiffResult diffResult = new DiffBuilder(firstBean, secondBean, ToStringStyle.SHORT_PREFIX_STYLE)
                        .append("id", firstBean.getId(), secondBean.getId())
                        .append("type", firstBean.getType(), secondBean.getType())
                        .append("conditionName", firstBean.getOther(), secondBean.getOther())

boolean hasDifference = diffResult.getNumberOfDiffs() != 0

Reference :
[1] DiffBuilder - Apache Commons

Remove password from your pdf payslips

by GarciaPL on Thursday, 22 February 2018

Within my previous employers, I was getting those payslips protected with a password. One day I thought what is going to happen if I would forget or lose the password! That's why I decided to write a small script in Python which might automate removing password from your payslip (or any other file).

# Requirements:
# pip install PyPDF2

import os
from PyPDF2 import PdfFileReader, PdfFileWriter

password = 'password'
directory = '/path/where/pdfs/are/stored'

def decrypt_pdf(input_path, output_path, password):
  with open(input_path, 'rb') as input_file, \
    open(output_path, 'wb') as output_file:
    reader = PdfFileReader(input_file)

    writer = PdfFileWriter()

    for i in range(reader.getNumPages()):


if __name__ == '__main__':
  newDirectory = directory + "/Decoded"
  if not os.path.exists(newDirectory):
  for filename in os.listdir(directory):
    if filename.endswith(".pdf"): 
      fullFileName = os.path.join(directory, filename)
      decrypt_pdf(fullFileName, newDirectory + "/" + filename, password)

Reference :
[1] Pastebin

Excel Power Query - Load JSON as a table

by GarciaPL on Sunday, 18 February 2018

If you would like to load JSON and present it as a table, it's quite easy if you have an Excel 2016 [1]. It's more complicated, once you have a lower version.

First of all, try to install an additional plugin called Power Query [2].

In the Power Query ribbon tab, click From Other Sources > Blank Query, then go to Advanced Editor and input below query string. Do not forget to change the path to your JSON.

Click -> Close & Load


Source = Json.Document(File.Contents("Z:\Directory\input.json")),
AsTable = Table.FromRecords(Source)



Click on 'Close & Load'
Reference :
[1] Microsoft Support - Connect to a JSON file
[2] Power Query for Excel

Creating release notes based on git commit history

by GarciaPL

If your JIRA does not support generating release notes because of for instance you do not fulfil Version field like in my case, there is a way to generate it based on git commit history.

First of all, you need to install a package called git-release-notes [2] via npm. It will allow you to generate release note page from git commit history using the following command :

git-release-notes 2.2.2..HEAD markdown.ejs >

Of course, 2.2.2 is a git tag.

You might also use mentioned above template called markdown.ejs which has been written in EJS [3]. In my opinion, this template gives more control in terms how release notes will look like at the end. Of course, you might also depend on built-in template into git-release-notes module.

<% commits.forEach(function (commit) { %>
    <% if(!commit.title.startsWith('[maven-release-plugin]')) { %>
        <%= '' + commit.title -%>
    <% } %>
<% }) %>

References :
[1] - Creating release notes
[2] NPM - git-release-notes

Removing duplicates by field/property in Java 8

by GarciaPL on Friday, 9 February 2018

How to remove duplicates in Java 8 using field or property ? We might use reduce!

List<MyClass> distinctByField = ArrayList<>(), (List<MyClass> accumulator, MyClass myClass) -> {
    if ( -> item.getField().equals(myClass.getField()))) {
    return accumulator;
}, (acc1, acc2) -> {
    return acc1;

Technical Debt - Identifying and Managing

by GarciaPL on Monday, 20 November 2017