Scala

ATDD, Generating random tests with ScalaCheck

Reading Time: 3 minutes Further, in our series on Acceptance Test Driven Development, we would look at generating random test values with the ScalaCheck framework. In our last post we looked at, how we make our test logic respect the DRY principle by defining the values in a table. However, in many situations, you would like to generate the values dynamically so that we do not have to fill Continue Reading

Scala Liftweb : Re render page element without making any request to the server

Reading Time: 2 minutes Lift introduces a powerful feature that enables developer to create rich interactive application using Comet and Ajax support . Using Comet , its easy to push content from server to browser by sending request asynchronously . AJAX works for a single client at a time , while Comet works for multiple users . Comet works like AJAX but in opposite direction . In this blog Continue Reading

An alternate way to implement JOINs in MongoDB [Update]

Reading Time: 2 minutes I have updated this blog . As last description was creating some misunderstanding and lot of confusion . In one of my project , there was a requirement to generate report in .csv format from MongoDB without using any reporting tool and any language . I had to use only MongoDB query . In that report , I had to use multiple collection . Since Continue Reading

Play Framework 2.0: Generate TinyUrl With goo.gl API

Reading Time: 2 minutes The Google URL Shortener at goo.gl is a service that takes long URLs and squeezes them into fewer characters to make a link that is easier to share, tweet, or email. Steps to integrate with goo.gl : Step #1 : Register App with Google Register your App with Google through the API Console.  When you create your application, you register it with Google. Google then provides information Continue Reading

ATDD, ScalaTest, Cucumber and respecting DRY

Reading Time: 3 minutes In our last post we looked at how it was easy to use ScalaTest for doing acceptance testing. In a post prior to that, we had looked at doing the same with Cucumber. We had also concluded that though acceptance tests could be written in the way described however, there was an issue. Writing the feature files with individual features having multiple scenarios which would Continue Reading

Play Framework 2.0: Connectivity with MySQL in Scala

Reading Time: < 1 minute Welcome to another week of KnolX sessions .The emphasis in this session is on How to connect a Play Application with Mysql as database in Scala.Play includes a simple data access layer called Anorm that uses plain SQL to interact with the database and provides an API to parse and transform the resulting datasets. Entire code can be found here: https://github.com/knoldus/FormDemoInPlayWithMysql

Akka Futures: Using For Comprehensions

Reading Time: 3 minutes In my previous post I discussed about composing Futures. I also discussed that Futures are monadic and they can be composed using map or flatmap. Since, for comprehension is just a sugar on top we can use it as well. Lets understand their usage in a bit more detail than my previous post. Using the same example of direct use of Futures and using a Continue Reading

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

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