Scalafmt – Styling The Beast

Knoldus Blogs

“I have never seen elegance go out of style” – SONYA TECLAI

Scala (The Beast) has imported efficiency and elegance to the programming world by combining coziness of object oriented programming with the magic of functional programming. This blog illuminates the work of Ólafur Páll Geirsson who has done a great job of styling the beast. In the bulk below I will discuss my experience of using Scalafmt, its installation process and some of its cool code styling features. Stuff we would be using in this blog

  • Editor -> Intellij (v 2017)
  • Build Tool -> sbt (v 0.13.15)
  • Language -> Scala (v 2.12.1)

One of the most important aspect of good code is its readability which comes with good and standard formatting. Ever wondered how an entire project having around 1000 Scala files of poorly formatted code could be formatted without having a headache? Well going shft + ctrl + alt…

View original post 634 more words


How to lazily evaluate collections in Scala

Knoldus Blogs

The Scala language provides to ways to implement the collections. One is strict and other is non-strict or lazy.

Whenever, the instance of a collection (except for the Streams) is created, it creates the strict version of the collection which means memory is allocated at the same time.

A simple example of strict collection is:

val list = List(1,2,3,4,5,6,7,8,9,10)
list: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

The above code, the memory would be allocated for the List immediately.

But whenever a view in the collection is created, it makes that collection as a lazy collection which means memory allocation would not be done at the time of initialization, instead, it would take place whenever they are actually accessed or some transformations are applied on them.

For example,

val listView = List(1,2,3,4,5,6,7,8,9,10).view
listView: scala.collection.SeqView[Int,List[Int]] = SeqView(...)

Here, the type of listView is SeqView[Int, List[Int]]

View original post 389 more words

Integration Test Configuration in Play Framework

Knoldus Blogs

A few days ago I’ve come across a problem while writing integration testing of my play application. My need was like to run unit and Integration test separately, in a normal sbt project, it’s easy to configure it, but I couldn’t find proper documentation about how to do this in play application, because there are difference in the folder structure in both of them.
The reason why I wanted to run unit and integration test cases separately because my integration tests take much more time as they call external web services.
So I came to know one easy solution, which I am going to explain, There are only 2 steps to do this.
1. You need to create a folder in your base directory eg. it, and put your all Integration test cases in that folder.

2. You need to configure your build.sbt file so it can understand where are all integration tests are placed

View original post 78 more words

Setting a git server in local area network

Knoldus Blogs

In this blog, we will learn to setup a git server in a system which will be accessible over the local area network.

First we have to setup SSH server to the system(Git Server), to provide access to other (git client) system. We will do this to get access to our git server, so git client will be able to push and pull code to git server. Both server and client have to install git as well.

Now create a user called ‘gitserver’ in Server and make sure clients can access this user without password.

Note: In this blog git server’s IP is and client’s IP is

Configurations at Server Side:

$ su gitserver
$ cd /opt/git
$ mkdir project.git
$ cd project.git
$ git init --bare

Note: This is to initialize empty Repository in /opt/git/project.git directory.

Configurations at Client Side:

$ cd project $ git init $…

View original post 43 more words

How to build secure Web Application

Knoldus Blogs

We all use web applications everyday whether we consciously know it or not. That is, all of us who browse the web.Now a days we have seen a significant surge in the amount of web application specific vulnerabilities that are disclosed to the public. No web application technology has shown itself invulnerable, and discoveries are made every day that affect both owners and users security and privacy.

Security professionals have traditionally focused on network and operating system security. Assessment services have relied heavily on automated tools to help find holes in those layers,so we need some guideline to build secure web application apart from networking and operating system concept.

Software is generally created with functionality first in mind and with security as a distant second or third. This is an unfortunate reality in many development shops. Designing a web application is an exercise in designing a system that meets a business need and not an exercise in building a system that…

View original post 889 more words

(Code Dissection) Akka Quartz Scheduler Scala’s way of scheduling(Part -2)

Knoldus Blogs

I hope you guys are doing good, and had a fresh breath. Put your mask again if you find the previous topic smelly, as we are going to finish up the dissection for Akka Quartz Scheduler. I am going to refer the every Quartz-Scheduler things prefixed with java. So when I say Java-Quartz-Scheduler, I mean the the quartz library which is made through java, and which is wrapped by the Akka Quartz Scheduler. And one more thing to noticed is that QuartzSchedules and QuartzSchedule are different.

Alright, so let’s start then. First let’s revisit some of the parts of Akka-quartz which will help us to do the dissection part easily. If you check the repo, you will find that the class that we interact with is the QuartzSchedulerExtension. First we initialize it and then schedule it. When we initializes it, we have some states(immutable) for itself, then the schedule…

View original post 1,105 more words

Vulnerability scanning with metasploit

Knoldus Blogs

Hola!! As you all aware of that vulnerabilities can cost you much more and as a developer you don’t need your website to have vulnerabilities (at least I am 😛 ).
And for testing for loopholes in your application can be painful, So here I am to show you a quick demo on how to test your web application for these vulnerabilities.

So we will use a known tool that is Metasploit, this is easy as well as powerful.
We will use two tools of metasploit

  1. msfcrawler
  2. wmap

Firstly we need to have metasploit on your machine, to do that follow below commands for ubuntu

> sudo apt-get install build-essential libreadline-dev libssl-dev libpq5 libpq-dev libreadline5 libsqlite3-dev libpcap-dev openjdk-7-jre git-core autoconf postgresql pgadmin3 curl zlib1g-dev libxml2-dev libxslt1-dev vncviewer libyaml-dev curl zlib1g-dev

Or you can follow the instructions from here

Metasploit comes pre-loaded with linux kali and Backtrack OS.

So now we all are…

View original post 195 more words