Archive

Archive for the ‘News’ Category

Capsules for recovering Scala fever.

Scala is a multi-paradigm programming language that combines the features of object-oriented programming and functional programming. The word “Scala” refers to “Sca(Scalable)+la(Language)” i.e designed to grow with the demands of its users. Scala runs on the Java Virtual Machine.

Here We’ll discuss about some of the basic concepts in Scala that make it distinct from other programming languages.Let us start with some of the following:


1. Simple method in scala:-

object Check {
   def countcharacter(a: String, b: String) = { //Declaring a method in scala
       if (a.length > b.length) println("The large word is" + a) 
       else  println("The large word is" + b) 
 }

  def main(args: Array[String]) {                 // The main method in scala
      countcharacter("Neelkanth","Sachdeva")     //calling the method
  }

}




2. Scala Array with “for” loop :-

object forloopdemo {
  
  val name= new Array[String](4)     // Declaring an Array in scala
  name(0)="This"
    name(1)="is"
      name(2)="an"
        name(3)="array"
  
  def printarrayelem(args:Array[String]):Unit={  

   /*Creating a method named "printarrayelem" with return type "Unit",
   that will print out all the elements in array.  */                                             
                                                     
  for(arg <- args)      
  /* A sample for loop for printing all elements in array. */                                                  
  println(arg)         
}
  
  def main(args: Array[String]) {    //The main method in scala
  printarrayelem(name)
  }
}

3. Constructor in Scala:-


class construct(val name: String, val age: Int) {                
println("This is the example program of primary constructor")
}

object PrimaryConstructor {
  def main(args: Array[String]) {           //the main method.
    val cons = new construct("Neelkanth Sachdeva", 23) 
     /*passing the values for name and age at the time of object creation. */                                                
                                                       
    println(cons.name)      // accessing the value via constructor.
  }
}


4. Companion Objects. :-

In Java, you often have a class with both instance methods and static methods. In Scala, you achieve this by having a class and a “companion” object
of the same name. The class and its companion object can access each other’s private features. They must be located in the same source file.

class companion{
  private var balance=0.0
  private def deposit(amount:Double){      //Declaring a private method
  balance+=amount
  println(balance)
  }
}
object companion {
  def main(args: Array[String]) {
  val n=new companion
/*Accessing the private method of class in its companion object.  */
  n.deposit(78.00)                
   }
 }

5. Bypass the main method :-
In Scala, you need not to have main method always, you can bypass the main method by extending the “App” trait as follows.


object main_alternate extends App{       //extending the "App" trait 
                                         //to avoid main method.
 println("This is the alternate of main")
}


6.ArrayBuffer in Scala:-
Most operations on an array buffer have the same speed as for an array, because the operations simply access and modify the underlying array. Additionally, array buffers can have data efficiently added to the end.Array buffers are useful for efficiently building up a large collection whenever the new items are always added to the end.
import scala.collection.mutable.ArrayBuffer
object arraybuffdemo {
  val abuf = new ArrayBuffer[Int]()        //Array buffer
  val array = Array(1, 2, 3, 4, 5)         //Simple array

  def main(args: Array[String]) {

    abuf += 1            //Inserting an element to buffer
    println(abuf)

    abuf ++= array      //Inserting a whole array to arraybuffer
    println(abuf)

    abuf.trimStart(1)   //removing one element from 
                         //starting point in arraybuffer
    println(abuf)

    abuf.trimEnd(1)    //removing one element from 
                         //ending point in arraybuffer
    println(abuf)

    abuf.insert(1, 80, 81, 82)  //inserting the three element 
                                //say 80,81,82 at index 1. 
    println(abuf)
       
    abuf.remove(1, 2)   //removing two elements from the index 1
    println(abuf)

 }
}

Enjoiii Scala!!!! :-)

Categories: News

Seasons Greetings and Best Wishes for 2012

December 25, 2011 Leave a comment

Festival and Holiday season is all around us. Many of us are already on holidays, taking well deserved break and having fun with family and friends. This is also a time to sit back, take a look how things went in past 12 months and plan for the coming year.

For Inphina, it has been an eventful year. We did projects on lot of new and diverse technologies like Google Fusion Tables, Maps, Google App Engine, Lift, Scala and lot more. Our partners list also increased substantially this year and we got opportunity to work with organizations from Singapore, Australia, Germany, UK, USA and of-course India. We started with CSD (Certified Scrum Developer) program and were the first one to execute it in India. Along with many successful public and private courses in India, we were able to take it outside India and did our first International CSD course in Kathmandu, Nepal. Most importantly, we had great fun and learning all through-out the year. We would like to thank all our partners for their confidence and support.

On behalf of everyone at Inphina, we would like to wish you and your dear ones a Merry Christmas and happy times in the year ahead.

Categories: News

Basic Http authentication in Lift.

Lift web framework accommodate a no. of conspicuous features that are implemented in a unique and solitary way as compared to other frameworks. Here we’ll discuss about the basic “Http authentication” mechanism for security in Lift.

What is ‘LiftRules’ singleton ?
Nearby all configuration parameters for the http requests and response are defined in LiftRules singleton. The important thing to notice is that we can only change the configuration parameteres of LiftRules only during boot but not at other times. You can find more about LiftRules Here.

Now for our purpose of Http authentication what all you have to do , is to add some Lines of code using the LiftRules singleton present in lift, in to your Boot.scala File and you’ll find all gets done for a basic http authentication.

Let us have a look to the steps for doing it ::

*Firstly in your Boot.scala file make the class extends Loggable(part of “net.liftweb.common”) as :

class Boot extends Loggable {
  def boot {
   LiftRules.addToPackages("XYZ")
.....
.....
} }



*Now you have to proceed with the ‘prepend’ method(from LiftRules package) implementation in your Boot(def Boot) method & defining the name of html pages on which you want to implement the authentication as follows:
 LiftRules.httpAuthProtectedResource.prepend{
      case (Req("html_page_name":: Nil,_,_)) => Full(AuthRole("admin"))
      case (Req("securepage":: Nil,_,_)) => Full(AuthRole("admin"))
                       
      
// Just mention the above code for page on which you
// want to implement the http authentication.   

    }


*Call the authentication(have root in ‘HttpAuthentication.class’) from the LiftRules and mention the username and password for the authentication purpose as :
LiftRules.authentication = HttpBasicAuthentication("Authenticate Yourself") {      
      case("user_name","password",req) => {
        logger.info("Authentication Succeeded...Welcome!!")
         userRoles(AuthRole("admin"))
         true
      }
    }



* Now each time when user will try to access the page,browser will pop up for the http authentication like: :-)


Http Authentication in Lift

Note:- Don’t forgot the following basic imports:

import common.{Loggable, Full}
import http._
import auth.{userRoles, HttpBasicAuthentication, AuthRole}


::: Want to get start with Lift ? come Here.

Categories: News

Mercurial Branching Cheat Sheet

December 15, 2011 Leave a comment

I have been using Subversion as source code version control tool since many years. Though I have used Mercurial for couple of hobby projects earlier but few weeks back, I started using it on my first Industrial project. Here, we are working on multiple feature-sets which need to go into Production at different time-lines. The best way to manage such scenarios is the use of branches. The concept and way of working with branches in Mercurial is quite different from Subversion. Here are few commands which one might find helpful while starting to work with Mercurial branches:

hg branches //shows all the branches present in the repository

There is always at-least one branch in Mercurial Repository which is called default as compared to trunk in Subversion.
hg branch new_branch_name //creates a new named branch

Named branches help in easy identification of the work being done on that branch.
hg commit //commits all the changes locally to the newly created branch
hg push --new-branch //pushes all the changes of this branch along with the branch to mercurial server

Only when we have committed and pushed our changes in newly created branch, other team members will be able to see the branch and our changes. Once a team member has committed the changes in a branch and other people would like to do further work on the same branch, they can use the following flow:
hg pull //gets all the changes on default as well as other branches
hg update -C branch_name //switches to the branch

On regular intervals, we will need to merge our changes from one branch to other for integrating different feature-sets. Following are the commands for the purpose
hg merge default //merges all the changes from default branch to your current working branch
hg commit //commits all the changes in your current working branch
hg push //pushes all the change-sets into the repository for other members to use them

For more detailed information on branching, please refer to branching tutorial available on Mercurial site.

Categories: News Tags: ,

Happy Diwali 2011

October 26, 2011 Leave a comment

Wishing you all a very Happy, Joyous and Fun-Filled Diwali 2011. We sincerely Thank you for all your support and hope the same for years to come.

Categories: News

Experiences at Cloud Computing Conference Pune 2011

I was one of the speaker of the second IndicThreads conference held at Pune on 3-4th June 2011.

Sessions at the conference dealt with key topics like Cloud Security, Amazon Elastic Beanstalk, Legal Issues in Cloud Computing, OpenStack, Xen Cloud Platform, Rails and CouchDB on the cloud, CloudFoundry, Gigapaces PAAS, Monitoring Cloud Applications, ORM with Objectify-Appengine, Scalable Architecture on Amazon AWS Cloud, Cloud Lock-in, Cloud Interoperability, Apache Hadoop, Map Reduce and Predictive Analysis.

My talk focussed on managing persistence on GAE. It dealt with choices available to a developer and then focussed on doing it with Objectify-Appengine.



Demo application is present here for download. For the instructions on how to run it please read the wiki.

Inphina Presenting on the Cloud Slam’ 2011 Today!

Inphina is one of the front runners on Google App Engine, at the Cloud Slam 2011. It is rubbing shoulders with some of the well known cloud vendors and niche technology organizations at the conference.

Today, I would be presenting on Multi-tenancy in the cloud and Google App Engine. As you would imagine, the session would have concepts around multi-tenancy, the current solutions and problems and the approach that GAE takes to resolve this issue. My slide deck for todays presentation is present here. Be sure to be online in around 3 hours from now to listen to our thoughts. Inphina has two complimentary passes for the conference. Contact us on cloud@inphina.com to get those. Of course the criteria is simple, you have to say good words about us ;)

Inphina Turns One !

They say that you have to be a fool to be an entrepreneur. We literally followed that saying to the core when we started the Inphina exactly one year back i.e. April 1′ 2010. From new kids on the block to seasoned strategic consultants, it has been quite a year.

We developed one of the most complex applications for a huge credit advisory in the US to do real-time alert processing and fraud detection using the power of complex event processing and grid computing. We helped 3 organizations to define their cloud strategy and move to the public cloud. We defined and executed the roadmap to move a highly successful timesheet and invoicing on-premise application to the Google App Engine, which eventually became a case study at various conferences. We also helped a large chain of restaurants in the UK to move their entire business to Google Apps and Google App Engine. We became the first company in India to offer CSD training with our partner for organizations and individuals who would like to improve their engineering practices and reap the full benefits of Scrum. We also became the first company in Delhi along with our partner to conduct one of the most talked about CSM and CSPO trainings. We helped a startup in the silicon valley to get their first round of VC funding by rapidly developing a high quality social network based marketing and analysis tool. Our enterprise monitoring product nearly won the top honors at the VC one-on-one. Our blogs are attracting more than 8K unique visitors per month. Phew! That does sound like a lot for year 1 ! I guess it is and probably that is the reason that during our first year itself we have been approached by two companies to buy stake in Inphina. Fortunately or unfortunately the deals did not work out but it left us flattered that our efforts are being recognized so quickly and the stake discussion made us a lot wiser (or at least we feel so ;) So, have we been killing ourselves to get here. Do you think there is another way? Ha ha kidding! Actually no! Our Agile practices and belief in quality with sound engineering hasn’t made the journey hard, at least uptil now. And we strive to work harder and are keeping our fingers crossed for the future.

So where do we go from here? We are already in discussion with one of the most geeky companies of the world to help them with their expansion plans in India. We are looking out for a new office space where we can expand our operations. We are lucky to have a solid team of Inphiners and are on the look out for more passionate people to join us (perks include 24/7 wii and playstation access, cool gadgets to impress your girlfiends, knowledge exchange iBAT evenings, guaranteed airtime at leading conferences with the kind of work that we do, best in class coffee machine and a refrigerator stacked with beer ;)

Our sincere thanks to our partners ( we have no clients) for helping us achieve what we have in the first year. Without your help I doubt if even a fraction of that was possible. We promise to stand by our commitments and would strive hard to ensure that the satisfaction level in our engagements is always north bound. Our sincere thanks to our families for supporting us through the thick and thin and of course our office manager RD who makes sure that the coffee is warm, the snack shelf is well loaded and the beer is chilled!

- The Inphina Team

Categories: News Tags: ,

Ooops!

April 2, 2010 3 comments

Oops … It seems that the cat ate all our posts! We should be back again with more insightful posts soon. Keep visiting!

Categories: News
Follow

Get every new post delivered to your Inbox.