I am happy to announce 0.4.0 version of strman library. strman is a Java 8 library to work with String. It implements a number of helper utility functions that you makes it easy to work with String. You can refer to strman documentation to learn about all the supported functions.
In this release, we have implemented following functions
- chop: This function chops the input String into parts
- dasherize: This function converts a underscored or camelized string into an dasherized one.
- humanize: This function converts an underscored, camelized, or dasherized string into a humanized one.
- lines: This function split input to lines
- zip: This function aggregates the contents of n strings into a single list of tuples.
- underscored: This function converts a camel or dashed string into an underscored one.
- isBlank: This function returns true if a string is blank or null and false otherwise.
Welcome to the first post of X-things-I-learnt-reading-Y’s-source-code series. In this blog series, I will share what I learnt after reading source code of popular open-source projects. Each week I plan to spend at least couple of hours reading source code of an open-source project and then sharing it on my blog. I plan to cover aspects such as design patterns project use, coding practices , API design, how they solved particular problem with their design, or any other aspect that I found useful to share. The purpose of this series is to learn how good developers design and build software. Then, I can apply these learnings to my work. Continue reading “10 Things I Learnt By Reading Retrofit Source Code”
Today a colleague asked me how he could unit test a Spring MVC REST resource. I am using Spring MVC test support for some time now so the obvious answer was to use
MockMvc. In case you have not used
MockMvc, it allows you to declaratively write tests for your Spring MVC controllers. Rather than calling controllers directly, you use the MockMvc fluent API to make a request to a URL and verify the response returned by the API. You can read Spring MVC documentation to learn about MockMvc in detail.
Continue reading “Unit Testing File Upload REST API using Spring MVC MockMvc”
Today, I decided use Teradata Covalent components in my Angular 4 application. After adding the dependency, my project stopped compiling. I started getting following errors
ERROR in /Users/dev/app//node_modules/@covalent/core/common/animations/toggle/toggle.directive.d.ts (2,10): Module "/Users/dev/app/node_modules/@angular/animations/animations" has no exported member 'AnimationBuilder'.
ERROR in /Users/dev/app/node_modules/@covalent/core/common/animations/fade/fade.directive.d.ts (2,10): Module "/Users/dev/app/node_modules/@angular/animations/animations:" has no exported member 'AnimationBuilder'.
I tried googling this error but couldn’t find a fix. Then, i looked at the Covalent Github repository to find the Angular version they are using. It turned out to be Angular version issue. I was using Angular 4.1.3 and Covalent needs Angular version 4.2.0 and above. After making the change, I was able to get my app working.
Today, I tried to play a video with
.mkv extension using VLC media player but I was greeted with error message. The problem is that VLC does not have the right codec to play the audio. So, video will work but there will be no audio 😦
VLC does not support the audio or video format “undf”. Unfortunately, there is no way for you to fix this.
The fix that worked for me was to update VLC to latest version. I was using VLC version 2.1.5 and I upgraded it to 188.8.131.52. This solve my problem and I was able to watch and hear video.
I am a big fan of Spring Boot. It is my preferred choice for building REST APIs in Java. It takes less than 5 minutes(given that you have Maven dependencies on your local machine) to get started with Spring Boot thanks to its auto configuration. In this blog, I will talk about a specific aspect of building REST API with Spring Boot. We will look at the request and response objects. The request object that you receive during the HTTP POST request and response object that you send in the response of HTTP GET request. I will discuss how you can keep these request and response objects to the bare minimum so that we can avoid writing and maintaining useless getters and setters.
Continue reading “Keeping Spring Boot Powered REST API Request and Response Objects Minimal”
If you use Docker for Mac or something similar, Docker Compose will be installed along with it. Docker Compose has a different release timeline for Docker for Mac so you will not be able to try latest version of Docker compose until you upgrade Docker for Mac. This is limiting. You should be able to install Docker compose independently. To achieve that, you can run following command
$ curl -L https://github.com/docker/compose/releases/download/$composeVersion/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose$ chmod +x /usr/local/bin/docker-compose
In the above commands,
$ signify bash prompt. You don’t have to type it. Now, you can check Compose version using the command shown below.
$ docker-compose version
One of the best talks on SOLID design principles and OO design that I have watched recently. This talk is 4 years old but more relevant today as many programmers are trying to follow functional programming bandwagon without understanding what they are getting into. One of the best advice speaker gave is to use OO at the outside boundary of your system and FP in the inside where you are doing data transformation and processing. A lot of good literature exists on OO design so let’s make read it and try to first do OO right.
This talk by Bret Victor is an eye opener. It was delivered by Bret in 2013. He gave this talk assuming we are in 1973 and then talked about how future of programming will look like in 2013. He talked about various CS discoveries and programming approaches people were trying during 1960 and 1970 era. At that time, nobody new what is correct way to program so they were experimenting with many different approaches. Nobody was fixated on one right approach so different approaches were tried.
Continue reading “Bret Victor Talk: The Future of Programming”