All posts by Anand Kumar Singh

About Anand Kumar Singh

Hi, I’m Anand Singh and I specialize in Computer Software. I’m passionate about what I do, and I love to help people. Nothing is more fulfilling than being part of a team with similar interests, and an organization that values its employees. I'm Lead Software Engineer at Sapient. Having 5+ years of experience in Java, Grails/Groovy and Scala language. Anand also knows about Javascript, jQuery, CSS and other UI design technologies. Certified developer in: * Principles of Reactive Programming – Coursera * Functional Programming Principles in Scala – Coursera * Functional Program Design in Scala – Coursera * Introduction to Big Data with Apache Spark – edX * Oracle Certified Associate (OCA) * Sun Certified Java Programmer (SCJP) I'm passionate to work with upcoming technologies and bleeding platforms providing the new way to programming & development. He is actively involved in development & maintenance of several software projects. He has been enjoying Scala for more than a year now. Anand completed his MCA from IGNOU. As a Developer, I'm continuing my journey by actively collaborating with other Developers in my field. I'm actively contributing on the TechMonad & Playing Scala platform. I likes to spend his free time in Cooking, watching Discovery for new Technology and visiting new places with friends.

Reverse engineering using Slick 3.2 and Scala

Knoldus Blogs

Sometime, we have requirements for create classes corresponding to the existing database or Sometimes, in our initial phase of project, we are going to design database and tables first, after that, we are going to create classes for mapping our tables.

As we know, Slick is a FRM(Functional Relational Mapping) for scala. Its a kind of ORM but for scala, it supports Functional and Reactive programming supports. Like in my Java experience with Hibernate, we are mostly use Jboss tools for reverse engineering from database tables to JavaPojo classes or Entities, Or While we are using JOOQ , JOOQ also provide some plugins for generate the code corresponding to tables.  Like, same as Hibernate, JOOQ and many more, Slick also provide a way for create classes corresponding to database tables by using Schema Code Generation.  Below are simple steps for generate scala…

View original post 1,950 more words

Internationalization with Play Framework(2.6.x)

Knoldus Blogs

In this blog, I will demonstrate how your application can support different languages using Play Framework 2.6.0 
What is Application/Website Internationalization ?
Application/Website Internationalization can be defined as a process of developing and designing an application that supports not only single language but also different languages so that it can be easily adapted by the users from any language, region, or geography. It ensures that the code base of your application is flexible enough to serve a new audience without rewriting the complete code or keeps text separate from the code base. 
Let us start the implementation step by step:
1. Specifying Languages for your application  
In order to specify Languages for your application, you need Language tags, which are specially formatted strings that indicate specific languages such as “en” for English, “fr” for French, a specific regional dialect of a language such as “en-AU” for English as used in Australia.
First, you…

View original post 394 more words

Try : Handling exceptions with grace in Scala. [Functional way with Scala]

Knoldus Blogs

Hey everyone, it’s time to continue our previous blog on how to make our code more robust, concise and better functionally defined at the same time. Here we are moving more towards Scala and leaving traditional Java behind. We will see new types and their usage along with the benefits we get from them.

This blog will show you the best way in my perspective to be used in order to handle the exceptions gracefully in Scala ( The beloved coding language for everyone here at Knoldus ) . Our methods would only be responsible for either returning the results or the exceptions, i.e. we will not write any try-catch blocks to handle the exceptions within different methods.

View original post 569 more words

Dribbling about Scala Value Classes, Universal Traits and Extension methods

In this blog , I will share my working knowledge on Value Classes, Universal Traits and Extension methods of Scala.

Let’s start with the Value Classes of Scala. In this section we will talk about Value Classes Introduction, Use Case and it’s limitations.

Value classes have been around in Scala for a long time internally, and we have used them already many times because all Number’s in Scala use this compiler trick to avoid boxing and unboxing numeric values from int to scala.Int etc.

As a quick reminder, let’s recall that Array[Int] is an actual JVM int[] which has tons of performance implications, but in one word — arrays of numbers are fast, arrays of references not as much.

In more specific technical terms Value classes are a new mechanism in Scala to avoid allocating runtime objects. This is accomplished through the definition of new AnyVal subclasses. They were proposed in SIP-15.


Ok, since we now know the compiler has fancy tricks to avoid boxing ints into Ints when it doesn’t have to. Let’s see how this feature is exposed for us, end users since Scala 2.10.x. The feature is called “value classes”, is fairly simple to apply to your existing classes. Using them is as simple as adding extends AnyVal to your class and following a few rules listed bellow.

  • Value Class must have only a primary constructor with exactly one public, val parameter whose type is not a value class. (From Scala 2.11.0, the parameter may be non-public.)
  • Value Class may not have specialized type parameters.
  • Value Class may not have nested or local classes, traits, or objects
  • Value Class may not define a equals or hashCode method.
  • Value Class must be a top-level class or a member of a statically accessible object
  • Value Class can only have defs as members. In particular, it cannot have lazy vals, vars, or vals as members.
  • Value Class cannot be extended by another class.

Now we have enough descriptions about Value classes. Let’s go with a simple example of it. I will be using Case (Value) Classes in all my examples here, but it’s not technically required to do so. We can implement a Value Class using a normal class with one val parameter instead, but using case classes is usually the best way to go.

case class Hour(value: Double) extends AnyVal {
  def toMinute: Minute = Minute(value * 60)

case class Minute(value: Double) extends AnyVal {
  def toHour: Hour = Hour(value / 60)

Now we need to know about two important keywords related to Value Classes which is Universal Traits and Extension methods.

  • A universal trait is a trait that extends Any, only has def s as members, and does no initialization. Universal traits allow basic inheritance of methods for value classes, but they incur the overhead of allocation.
  • Extension methods serve the same purpose as Implicit conversions (which are a more general and more powerful utility), yet are better than conversions in one simple way — they avoid having to allocate the “Wrapper” object, which implicit conversions would otherwise use to provide the “added methods”. Extension methods take the route of rewriting the generated methods a little, so that they take the type-to-be-extended as their 1st argument.

These are the basics around Value Classes, Universal traits and Extension methods. If you want to read more about the different edge-cases around them, please refer to the official documentaion’s section about Value Classes where Mark Harrah, explains them very well with tons of examples, so I won’t be duplicating his effort here beyond the basic introduction 🙂 . As next step, I would look at how I can explain the use case of Value Classes and It’s functionality 🙂 Stay tuned.

Handling HTTPS requests with Akka-HTTPS Server

Knoldus Blogs

Hi guys,

In my last blogs I explained how one can create a self-signed certificate and KeyStore in PKCS12. You can go through the previous blog, as we’ll be needing certificate and keystore  for handling HTTPS requests.


Akka-HTTP provides both Server-Side and Client-Side HTTPS support.

In this blog I’ll be covering the Server-Side HTTPS support.

Let’s start with “why do we need server-side HTTPS support?”

If we want the communication between the browser and the server to be encrypted we need to handle HTTPS request.  HTTPS is often used to protect highly confidential online transactions like online banking and online shopping order forms.

Akka-HTTP supports TLS(Transport Layer Security).

For handling the HTTPS request we need to have the SSL certificate and the KeyStore. Once you have generated both you can go through the example.

In this example, you will see how easily you can handle

View original post 219 more words

Lambda Architecture with Spark

Knoldus Blogs

Hello folks,

Knoldus  organized a knolx session on the topic : Lambda Architecture with Spark.

The presentation covers lambda architecture and implementation with spark.In the presentaion we will discuss components of lambda architecure like batch layer,speed layer and serving layer.We will also discuss it’s advantages and benefits with spark.

You can watch the video of presentation :

Here you can check slide :

Thanks !!


View original post

Finding the Impact of a Tweet using Spark GraphX

Knoldus Blogs

Social Network Analysis (SNA), a process of investigating social structures using Networks and Graphs, has become a very hot topic nowadays. Using it, we can answer many questions like:

  • How many connections an individual have ?
  • What is the ability of an individual to influence a network?
  • and so on…

Which can be used for conducting marketing research studies, running ad campaigns, and finding out latest trends. So, it becomes very crucial to identify the impact of an individual or individuals in a social network, so that we can identify key individuals, or Alpha Users (term used in SNA), in a social network.

In this post we are going to see how to find the impact of an individual in a Social Network like Twitter, i.e., How many Twitter Users an individaul can influence via his/her Tweet upto N number of level, i.e., Followers of Followers of Followers… and so on. For, this…

View original post 572 more words

Knolx: Introduction to KnockoutJs

Knoldus Blogs

Hello all,

Knoldus organised a session on Friday, 07 October 2016. In that session, we had an introductory session on Knockout js.

Knockout is a JavaScript library that helps you to create a responsive display(UI). It is based on Model–View–Viewmodel (MVVM) pattern. It provides a simple two-way data binding mechanism between your data model and UI

The slides for the session are as follows:

And, you can also watch the video on youtube link is as follows:


View original post