Design benchmarks

This is a long-form write-up. The comment that goes something like this.,

Which means that the people who speak louder online, with higher frequency and reach, are not necessarily the ones striving for Independence, Depth, Honesty, or Breadth through the content they create. They are not necessarily the ones equipped with the experience and knowledge required to share thoughts that will provoke change in our industry.

This is such a genuine opinion, beats the odds that, if you are an individual who is an industry trendsetter, then you do not have time to write about the content that you are working on. So anyone who has the power and time to write will have a perspective on how design should be.

 

Quickest way of getting an custom error message in Spring Boot 2.x

There are different ways to get a custom error message page in spring boot. The following solution worked for my web project. Here is the overview of the structure.

Pic Pic

To start with, if there is 404 error, then we want a custom error page showing up instead of the spring boot’s default page.
The first thing we are going handle is to suppress the boot framework’s error page. For this, we will go to the application properties and add the following line

server.error.whitelabel.enabled=false

As we are done with that, now let us implement the ErrorController interface. The thing to keep in mind is, we have the LOG entry that says what happened to the code base as we reached here. Here is the sample code.

 

@Controller
public class ITContractErrorController implements ErrorController     {
    public static final Logger LOG = LoggerFactory.getLogger(ITContractErrorController.class);
    @Autowired
    ErrorAttributes errorAttributes;
    @GetMapping({"${server.error.path:${error.path:/error}}"})
    public String handleError() {
        LOG.error("Sever error occured");
        return "/error/error.html";
    }
@Override
public String getErrorPath() {
    return "error";
    }
}

One other way that we can add the custom error message is using the Spring 2.x’s ConfigurableServletWebServerFactory implementation. We add this to the main method of the web module. Here is the sample code for this entry.

 

@SpringBootApplication
public class SkminfycontractorWebmoduleApplication {
    @Bean
    public ConfigurableServletWebServerFactory         containerCustomizer(){
        TomcatServletWebServerFactory factory = new     TomcatServletWebServerFactory();
        factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,     "/error/error.html"));
        return factory;
    }
    public static void main(String[] args) {
        SpringApplication.run(SkminfycontractorWebmoduleApplication.class, args);
    }
}

One thing to remember is, when we implement the override with ConfigurableServeletFactory then Override that is ErrorController is gone.

There is a lot of best practice information laid out in spring documentation and other places. But none worked for my setup. I will update this entry if I find a more interesting solution.

Free-code camp Inventory update solution

One other interesting problem with the inventory update challenge from freecodecamp. After this, it is going to be the modules for creating calculators and other challenges.


function updateInventoryWithArr(curInv, newInv) {
    var arr1 = curInv;
    var arr2 = newInv;
    var finalOutPutArr = [];
    var arr1Map = new Map();
    var arr2Map = new Map();
    var arr3Map = new Map();
    for (var j = 0; j < arr1.length; j++) {
        var data1 = arr1[j][1];
        var data2 = arr1[j][0];
        arr1Map.set(data1, data2);
        arr3Map.set(data1, data2);
    }

    for (var i = 0; i < arr2.length; i++) {
        var keyVal = arr2[i][0];
        var lookupKey = arr2[i][1];
        var keyData = arr1Map.get(lookupKey);
        var sumVal;
        if (typeof keyData != 'undefined') {

            sumVal = keyVal + keyData;
            arr3Map.set(arr2[i][1], sumVal);
            arr2Map.set(sumVal, arr2[i][1]);
        } else {
            arr3Map.set(arr2[i][1], keyVal);
            arr2Map.set(keyVal, arr2[i][1]);
        }

    }

    var dataInf = Array.from(arr3Map);
    for (var k = 0; k  b[1]
    });
    return finalOutPutArr;
}

Bootstrap 4 Tutorial

One of a kind tutorial, packed with all that is needed to start Bootstrap 4. When we are debugging an issue for some server side issue, we will need to know a lot of nit-picky details of Bootstrap. But this was a quite a walk thro’ of all the items that are needed to know and read the bootstrap code.