scala

Integrate Github Repo with Travis CI For Scala Play2.0 and MongoDB Project

Reading Time: 2 minutes Travis CI is a hosted, distributed  continuous integration service used to build and test projects hosted at  GitHub for the open source community. It supports building software in numerous languages, including Ruby, JavaScript, Java, Scala, PHP, Haskell and Erlang. A Travis worker comes with a good amount of services you might depend on, including MySQL, PostgreSQL, MongoDB, Redis, CouchDB, RabbitMQ, memcached and others. Hosting your project Continue Reading

Akka Actor And Futures

Reading Time: < 1 minute This presentation was presented at Knolx session. It was presented before my last post on Akka Futures with a simple example. It focusses on Akka 2.0 and Akka Futures. Please note that in latest Akka version which is for scala 2.10, Scala Future and Akka Future has combined. This presentation caters to Akka 2.0.5 version. This talk is inspired by Viktor Klang talk on Akka Continue Reading

ATDD, Cucumber and Scala

Reading Time: 4 minutes Acceptance Test Driven Development (ATDD) is a practice in which the whole team collaboratively discusses acceptance criteria, with examples, and then distills them into a set of concrete acceptance tests before development begins. If you notice the keywords here then they are whole team discussion acceptance criteria with examples concrete acceptance tests before development begins Hence, just like we do TDD for development, ATDD is Continue Reading

Design Forms In Play2.0 using Scala and Mongodb

Reading Time: 2 minutes The play.api.data package contains several helpers to handle HTTP form data submission and validation. In This blog we would learn how to design forms with validations in play2.0 using scala and how to communicate  with database using mongodb. Step 1: Create New Project in play2.0 lets say FormDemoInPlay Step 2: Dependency for Mongodb In Build.scala [sourcecode language=”scala” wraplines=”false” collapse=”false”] "com.novus" %% "salat" % "1.9.1" [/sourcecode] Step 3: Continue Reading

OOPs concepts and Scala

Reading Time: < 1 minute Recently Knoldus delivered a training at a huge bank in Singapore and Mumbai, India to get them started with Scala. The team mostly coming from the imperative background was first updated on the best way to develop software in an object oriented way and then for 3 days were immersed in the Scala sessions. What follows is the part one where the team was reinforced Continue Reading

Communicating with Twitter via Twitter4J using Scala

Reading Time: 2 minutes Twitter4J is a Java library for the Twitter API. With Twitter4J, you can easily integrate your Scala application with the Twitter service. Twitter4J is featuring: – Easy to use with Scala (as it works on any Java Platform version 5 or later) – Support via a single jar file. – Built-in OAuth support. Here is the tutorial to use Twitter4J in Scala. 1. Download the Continue Reading

Getting a preview image of a PDF file in Scala

Reading Time: < 1 minute In order to have an preview image of an PDF file you can use PDFBox. Here is the simple tutorial to extracting an preview image of an PDF file. Firstly you need to get the pdfbox-jar file & you can get it here. 1. You need to have these following imports. import java.io.FileInputStream import javax.imageio.ImageIO import org.dopdf.document.model.PageDetail import org.dopdf.document.read.pdf.PDFDocumentReader import java.io.ByteArrayInputStream import utils.AmazonUpload import java.io.InputStream Continue Reading

ScalaKnol: Understanding Traits as Stackable Modifications

Reading Time: 3 minutes Traits can be used to modify the methods of a class. The way such modifications are carried out is such that they can stack modifications with each other. Let us take an example. Say, there is a class called ImageProcessor which processes images. Now there are a few modifications required before the image is actually uploaded to your server. If you are using Facebook then Continue Reading

Knolx Session: Data Structures In Scala

Reading Time: < 1 minute This Knolx session we went about discussing data structures. I talked about simple data structures like Queue and Binary Search Tree and their possible implementation in Scala. The idea was to know about a bit of Functional data structures and their implementation in Scala. I then discussed Binary Search Trees and their traversals. Here is the presentation.

Extract a frame image from video in scala

Reading Time: 2 minutes Sometimes it becomes a general requirement to show the preview of a video wherever video gets displayed. Like on YouTube , If you’ll right click on almost any video , you’d find that each video contains a preview image of a frame of that video. Here is a short tutorial for doing the same i.e extracting a frame image from a video in Scala via Continue Reading

ScalaKnol: Understanding Uniform Access Principle

Reading Time: 2 minutes The ScalaKnol series attempts to share a nugget of Scala wisdom every few days or sometimes few times a day. Keep tuned. Today we would look at the Uniform Access Principle. The principle states that the client code or the calling code should not be affected by the decision to implement an attribute as a field or a method. Hence essentially irrespective of whether the Continue Reading

ScalaKnol: Understanding Loan Pattern

Reading Time: 2 minutes Loan Pattern as the name suggests would loan a resource to your function. So if you break out the sentence. It would Create a resource which you can use Loan the resources to the function which would use it This function would be passed by the caller The resource would be destroyed As you would see, the advantages are multifold. First, I am not constrained Continue Reading

ScalaKnol: Why returning a value in finally is a bad idea

Reading Time: < 1 minute For those of us who are coming from an imperative background, we are used to using try catch rather losely. Ok, I am not trying to generalize here but a majority of us do so. When we come to the Scala world, we realise that like other expressions in scala, try-catch-finally would result in a value. The general practice recommended is that finally should be Continue Reading