Scala

Communicating with Twitter via Twitter4J using Scala

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

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

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

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

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

Working With Elasticsearch In Scala

Elasticsearch is an open-source, restful, distributed, search engine built on top of apache-lucene. You can read it more on their website. We have an application built in scala with sbt as our build tool. Now we required to have a search capability on the output created by the application. We chose to use elasticsearch for our application. In this post, we will learn to use Continue Reading

ScalaKnol: Understanding Uniform Access Principle

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

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

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

SICP Chapter 1 Solved with Scala

Ok, let us get the facts right. We have not provided solution to each exercise but the solutions that we have provided would be good for you to understand the concepts. It would also help you realize how efficiently we can use higher order functions in Scala. The Structure and Interpretation of Computer Programs (http://mitpress.mit.edu/sicp/full-text/book/book.html) is a seminal book which helps you reason and understand Continue Reading

Play with Lift’s Autocomplete Widget using Scala-One of the Best Feature of LiftWeb Framework

The AutoComplete widget provides a flexible and accessible way to offer suggestions or some kind of filtering information as a user type text information in an input field . If you have used Google , you might see that Google starts providing autocomplete suggestion with entries depending on user’s current input . Lift provides a very easy way to implement Autocomplete using Scala . Here Continue Reading

Empower Scala with Apache Solr

Solr is ready to use enterprise search server. Here I am going to show you how we can use both of them together to empower your scala application with solr. Solr is able to achieve fast search responses because, instead of searching the text directly, it searches an index instead. This is like retrieving pages in a book related to a keyword by scanning the index Continue Reading

Annotations in Scala

In this session, we will learn about annotations. Firstly, we will see the definition of annotation, standard annotations and then we will learn to write our own annotations. As of now, with Scala we can create compile time annotations (could we create runtime ones without resorting to Java?). For example, if you look at the @tailrec annotation in Scala then it would verify that the Continue Reading

Knoldus Pune Careers - Hiring Freshers

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