Functional Programming

Multi Project Builds with SBT 0.12 for Scala Project

Reading Time: 3 minutes In my last post Create Scala Project with SBT. We had seen how it was easy with SBT to create a Scala project. In this post,we will learn multi Project Builds with SBT for Scala project. It can be useful to keep multiple related projects in a single build. If they depend on one another and you tend to modify them together. Each sub-project in Continue Reading

Advertisements

ATDD, ScalaTest and Scala

Reading Time: 3 minutes In my last post on ATDD, we had seen how it was easy with Cucumber to write a feature file and share it with our stakeholders in order to validate our understanding of the functionality. The idea again is to build the right software right. In this post, we would learn how to do ATDD with ScalaTest but before that let us do a recap Continue Reading

Play Framework : Uploading a file to server

Reading Time: < 1 minute In order to upload a file to server we used to use the form with multipart/form-data encoding. File upload is very easy with Play. Use a multipart/form-data encoded request to post files to the server, and then use the java.io.File type to retrieve the file object. Let us see how we can handle the file upload within Play framework. Writing an HTML form: @helper.form(action = Continue Reading

Creating Scala Project With SBT 0.12

Reading Time: 2 minutes I have recently started working with scala. SBT is the tool of choice for Scala based projects. Let us see how to get it working on windows. Installing SBT for Windows Create a batch file sbt.bat which contains following script $ set SCRIPT_DIR=%~dp0 $ java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %* Now, put the sbt-launch.jar file in same directory where you put sbt.bat file.Put sbt.bat on your Continue Reading

Dependency Injection In Scala using Self Type Annotations

Reading Time: 5 minutes Dependency injection is a software design pattern that allows removing hard-coded dependencies and making it possible to change them, whether at run-time or compile-time. Dependency Injection has three kind of software components 1. Dependent or Consumer : Describe what software components, it depends on . 2. Dependencies on which consumer depends 3. Injector also known as provider : Decides what concrete classes satisfy the requirements Continue Reading

Scala LiftWeb: Upload File using AJAX

Reading Time: < 1 minute Liftweb provides AJAX functionality for all html elements except file upload using Scala . But there is a way to upload file using AJAX by binding form as AJAX form . 1) add below lines in your html . <div class="lift:FileSnippet.uploadFile"> Upload File : <input name="upload" type="file"></input> <input type="submit" name="submit" value="Upload"/> </div> 2) class FileSnippet { def uploadFile(form: NodeSeq): NodeSeq = { def handleFile():JsCmd = Continue Reading

Play With Liftweb’s AJAX Generators using Scala

Reading Time: 2 minutes AJAX is an approach for building dynamic web content on the client side . In Liftweb , we can implement this approach either by AJAX or by Comet . Comet is like AJAX , except in opposite direction . AJAX model increases the richness of the User Experience for a single client at a time, Comet can do the same for multiple users. First thing Continue Reading

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

Scala Liftweb : Use Forgot Password Inbuilt Functionality to send Email with Unique Token

Reading Time: < 1 minute If you are implementing Forgot password functionality in your web application using Liftweb and you have such a scenario where you have to send redirect URL with unique token in Email , Liftweb with Scala provides a wonderful functionality to handle this . 1) Write a function to send URL with unique token in Email . def sendLoginToken(user: User): Unit = { import net.liftweb.util.Mailer._ val Continue Reading

Akka Futures In Scala With A Simple Example

Reading Time: 3 minutes We use Akka Futures extensively for a product built to handle huge load of streaming data. We have been early adopters of Akka and been using it right from its Akka 1.1.X days. We found Futures as simple yet powerful tool to add concurrent behavior in our application. This post emphasizes importance of Akka Futures with a short and easy to understand example application. Please Continue Reading

Knoldus Pune Careers - Hiring Freshers

Get a head start on your career at Knoldus. Join us!