Archive

Archive for the ‘Web’ Category

Using RDBMS on Google App Engine : Google Cloud SQL

December 16, 2011 5 comments

We have been working on Google App Engine since its early days and have developed and ported several applications on the platform for our clients. One of the major hinderance for our Enterprise clients for not being able to move to GAE has been Datastore being the only storage option available till date. Major reasons for these enterprises not using Datastore are:

  • (In case of migration) Substantial efforts in adapting the application code base to Google Datastore specifications
  • Potentially huge data-migration efforts
  • Vendor Lock-In as both the application code and data residing in Datastore can’t be taken to an in-premise Infrastructure or another cloud platform seamlessly

Keeping all these requests and potential business opportunities in mind, Google has recently announced Cloud SQL.

What is Google Cloud SQL

  • It’s a Relational Database on Cloud offering from Google.
  • Offers MySQL Database environment with JDBC support for Java applications and DB-API support for Python applications.
  • Being a service on Cloud, it offers traditional advantages of any Cloud service like no maintenance, administration, replication and backup efforts
  • To ensure high-availability, data gets replicated across multiple geographic regions
  • Easy to use Web-Interface for managing multiple Instances

Google Cloud SQL & Google App Engine

A very good integration has been provided for your applications running on Google App Engine to use Google Cloud SQL as back-end storage mechanism. Furthermore, one SQL instance can be shared across multiple Google App Engine applications. This feature should be quite helpful as often we have a family of Web Applications for different user-requirements but still sharing the same Database.
Read more…

Categories: Cloud, Java, Web Tags: ,

Create web application menus using the Lift web framework

September 30, 2011 1 comment

Lift is a powerful & secure web framework having elegant features and also stresses the importance of security, maintainability, scalability and performance. Lift applications are written in Scala.

Here we will discuss about creating the menus in Lift. These are the approaches to create a menu:

  • Define the url names and routes directly in Boot.scala.
  • Create the seperate Singleton for defining menu items.

Let us see how this works:

Define the url names and routes in Boot.scala

class Boot {
  def boot {
    // where to search snippet
    LiftRules.addToPackages("demo.helloworld")

    // Build SiteMap
    val entries =
      Menu(Loc("Home", List("index"), "Home"))::
      Menu(Loc("Items", List("items"), "Items")) ::
      Menu(Loc("Search", List("search"), "Search")) :: Nil

    // Sitemap
    LiftRules.setSiteMap(SiteMap(entries:_*))

  }
}

And here is the output:



Create the seperate Singleton for defining menu items

We will define the sitemap in Boot.scala. Sitemap will obtained from the Application Singleton

class Boot {
  def boot {
    LiftRules.setSiteMap(SiteMap(Application.sitemap: _*))
  }
}

Now define your menu items in this seperate singleton say "Application" singleton.

object Application {
  // Sitemap
  val sitemap = List(
    Menu.i("Items") / "items",
    Menu.i("Search") / "search"
  ) ::: User.menus
}

When working with html pages always provide the links to pages corresponds to as defined in your singleton's sitemap e.g

  <li><a href="/items">Items</a></li>
  <li><a href="/search">Search</a></li>

Lift will search for corresponding HTML pages defined either in Boot.scala or in Application.scala in src/main/webapp folder.

Categories: Scala, Web Tags:

Hot reload / Build on save for Adobe Flex

September 26, 2011 Leave a comment

If you’re not using Adobe Flash Builder for developing Adobe Flex apps, you might be missing the build on save (or build automatically / hot reload) feature.

Here’s a little Node.js utility that does the same. While working on Flex with gedit (or any other text editor), just keep “hotflex” running in the background. It watches all MXML and AS3 files and rebuilds the project on save.

Screenshots

This slideshow requires JavaScript.

Dependencies

Node.js and NPM are required, refer to – Setup Node.js and NPM on Ubuntu

For notifications on Ubuntu, install libnotify-bin:

    sudo apt-get install libnotify-bin

Install

From NPM:

    sudo npm install hotflex -g

From GitHub

    git clone git://github.com/Srirangan/hotflex.git
    cd hotflex
    sudo npm install -g

Configure

You will need to create a hotflex.json file containing the following parameters:

    { "source": "./src/main/flex/main.mxml"
    , "sourceFolder": "./src"
    , "target": "./bin/main.swf"
    , "lib": "./lib"
    }

The lib parameter is optional while the rest are mandatory.

Run

Execute hotflex from the folder containing the hotflex.json file, preferably your project root.

hotflex

Meta

GitHub repository – https://github.com/Srirangan/hotflex
NPM – http://search.npmjs.org/#/hotflex

To do

  • Integration with Adobe Flex Compiler Shell fcsh for faster builds
  • Integration for Growl for OSX notifications. Currently notifications work for Ubuntu.
Categories: Web Tags: ,

Generating Heat Map with Fusion Tables

August 31, 2011 1 comment

I have been discussing about capabilities of Google Fusion Tables in past couple of blogs. Continuing with the topic, I would like to talk about Heat Maps with Fusion Tables.

What is Heat Map For people who are not aware, the definition from Wikipedia says “A Heat Map is a graphic representation of the values taken by a variable from a table and represented as Colors”. A Heat Map uses different colors to represent the relative intensity of the variable. As an example, areas with low variable occurrence can be represented with Green, moderate with Yellow and high occurrence with Red color. Heat Maps along with location aware data can come as very handy way for representing data changes across different regions and time-lines. Following are some of the very popular use-cases of Heat Maps:

  • Population Layout
  • Voter behavior during Elections
  • Incidence Occurrences
  • Activity Levels

Of-course the usage is only limited by your imagination.

How to generate Heat Map with Google Fusion Table Data As mentioned in my previous posts as well, Fusion Tables allows you to add a layer over top of Google Map. For that, your data needs to have location information as well. Let’s take an example from publicly available data about Earth Quakes (4.5+ magnitude) happened anywhere in the World since 1973. A snapshot of the data is :

year,month,day,time,location,mag,depth
1973,01,01,034609.80,"-9.214, 150.634",5.3,41
1973,01,01,052229.80,"-15.012,-173.958",5.0,33
1973,01,01,092857.20,"-22.161, -65.792",4.8,205
1973,01,01,114237.50,"-35.513, -16.211",6.0,33

You can access the complete table data from here. Generating Heat Map from this table data using Fusion Tables is very simple:
Read more…

Categories: Cloud, Web Tags:

Fusion your Data and Map using Google Fusion Tables

August 17, 2011 2 comments

Lot of us use Google or other Map implementation for either finding a location, getting directions from one place to another or similar other purposes quite regularly. On a different note but very similar in terms of frequency, we often work with data, in-fact lots of data in our day-to-day work and would like to share and present it to people. The data is generally available to us in form of XLS spreadsheets, CSV files and back-end data-bases. Presentation of this data to a varied group of people may become tedious who may want to look and analyze it in different ways. Would it not be nice, if there is a way to store and present our data online in different formats. Even better (provided the data has geographical association), if we can over-lay it on a Map.

Google has come up with a solution to these issues in form of Google Fusion Tables. Here are some of its offerings:

  • Upload location aware data on Fusion Tables and publish on Google Maps
  • Represent in different Chart forms (Bar, Line etc)
  • Represent in form of Motion and TimeLines
  • Represent in form of HeatMap and Intensity Maps

Hello World on Google Fusion Tables Let’s start with a simple scenario where a Company is having multiple offices around the World, with information about the employee strength and revenue details from each of these regional offices. We would like this information to be displayed on Google Map.
Read more…

Google Apps Script And Getting Site Context

Google Script UI services enables to create rich UI in Google Sites. There is a bug where there is no way to find out directly where Google Apps Script is embedded in Sites. If you are faced with similar dilemma and need a workaround read on. This a critical issue when a script intended to be executed for multiple sites.

In our case the requirement was to fetch the data for site instances from the spreadsheet. Site instances were created from a template Site. The template Site containing the apps script required to know the active site, or in other words the UI apps script required to know the context of the site it is embedded in.

There is an existing method SitesApp.getActiveSite() which runs perfectly for the Script but fails when it is coded in Google UI Script. You can read more of it here.

The solution was suggested by Rahim where he found a way to wrap the Google Apps UI Script in a Google Widget and pass Site URL reference parameter to the UI script.

The Google Widget xml file has a reference to the published UI script url and it uses document.referrer javascript to get the URL where it is embedded in. This is how the Google Widget looks like.

<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Company Description" />
  <Content type="html"><![CDATA[<div id="txt"></div>
  <iframe id="gdgt" frameborder="0" height="100%" width="100%"></iframe>
  <script type="text/javascript">
  document.getElementById('gdgt').src='publishedUrl&siteurl=' + document.referrer;</script>
]]></Content>
</Module>

Read more…

Categories: Java, Web Tags: ,

Get started with Django .. django-kick-start!

May 22, 2011 Leave a comment

The Django Framework is an extremely popular and powerful Python based framework for web application development. The project began way back in 2003 and have for the past few years really matured and has gained mainstream and enterprise adoption.

I recently conducted an intensive training session titled “django-kick-start” at the Inphina iBat dated 21st May 2011.

Download source code


Srirangan is a programmer / senior consultant with Inphina Technologies
Blog   GitHub   LinkedIn   Twitter

Categories: Web Tags: ,

Flex 4.5 with IntelliJIDEA | Screenshot Guided Tour

May 11, 2011 6 comments

I used to be a Windows, Flash Builder, Eclipse user but I have since migrated to Ubuntu 11.04 and IntelliJIDEA. I would have migrated earlier than I eventually did but one of the things holding me back was the lack of a mature Flex development environment on Ubuntu.

This has now changed and am working with Flex 4.5 SDK on IntelliJIDEA + Ubuntu and I feel more productive than ever before. Listed below are steps for you to get started with developing Flex 4.5 applications on IntelliJIDEA:

  1. Assumption – You have downloaded Flex SDK 4.5 and have a working installation on IntelliJIDEA. Additionally you have downloaded the Flash debug player (projector) for Linux.
  2. Add Flex 4.5 SDK to Global SDKs – Launch the Project Structure window through the file menu or Ctrl + Alt + Shift + S. Under Platform Settings select the SDKs option and add the Flex 4.5 SDK. You should know the path where Flex 4.5 SDK has been extracted.
  3. Add Flex 4.5 SDK as a Module Dependency – Under Project Structure select Modules, further select your Flex module and set Flex 4.5 SDK as Module SDK and it to the Dependencies if not already present.
  4. Fast Flex Compiler – Open Settings via the file menu or Ctrl + Alt + S, select Flex Compiler and choose the Flex compiler shell for fast Flex compilations. Using Built-in compiler shell did not work for me with Flex 4.5 SDK.
  5. Edit configuration with Flash debugger – Create a new Flex run configuration and select the Flash Player Debugger as the Launch Application.
  6. All set to go!


Srirangan is a programmer / senior consultant with Inphina Technologies
Blog   GitHub   LinkedIn   Twitter

Categories: Web Tags: , ,

Send JSON objects over Adobe Flex HTTPService call

March 3, 2011 2 comments

It was either incredibly difficult to locate decent references for, or me being incredibly stupid     <– look me indulging in self-degradation and not pompous bragging as often accused by some team members ;-) but I ended up spending all day trying to figure out how to send a JSON object / string over an HTTPService call. It turned out to be quite simple in the end and a thank you goes to Wetfeetblog.com and Tomas Mazukna.

Here’s how it is done:

var httpService:HTTPService = new HTTPService();
httpService.contentType = “application/json”;
httpService.resultFormat = HTTPService.RESULT_FORMAT_TEXT
httpService.send(“…json..string..here…”);

You may end up using AS3Corelib‘s JSONObject to encode your objects as a JSON string:

httpService.send(JSON.encode(..yourObject..));

..and that is all. It is now ready to be consumed by your RESTful service and converted into a plain old object and / or entity depending on what you’re using back there.

PS: Yes, my Flex skills are a bit rusty :-p

Categories: Web Tags: , , ,

Most suitable Twitter API for your App

February 6, 2011 Leave a comment

If someone asks me why I think Twitter has been hugely popular, I would list these reasons:

  1. Simplicity in concept and use
  2. Celebrities
  3. Awesome APIs –> Awesome Apps

In this blog post, I’ll focus on the three APIs Twitter provides – what they are and when they can be best used.

The three APIs are:

  • Twitter Rest API
  • Twitter Search API
  • Twitter Stream API

Twitter REST API
When you look to use the Twitter REST API you can can expect it to be able to perform all tasks that a User would perform on http://twitter.com/ Sample use-cases for the Twitter REST API would involve getting a user’s timeline, favorites, followers, users he/she follows, direct messages, send a tweet, send a direct message etc. All Twitter client apps would have to make use of the Twitter REST API although it is possible that popular Twitter clients such as TweetDeck would internally use Search and Stream APIs in addition to the Twitter REST API.

Twitter Search API
The Twitter Search API allows you to search for public Tweets based on keywords, geo-code and other parameters. The Search API results can be fetched as JSON or ATOM (XML Feed) content. It is important to note that the search is only made on Tweets made in the past. It does not provide you real time Tweets.

Enter .. Twitter Stream API
Open up a stream — pre-filtered by keywords, geocode, users etc. — and let your App receive real time Tweets. This throws up a user authentication layer as well and lets you hone in and listen to User Streams or Site Streams. While User Streams are specific to a single user a Site Stream let’s you “multiplex” multiple users onto a single stream.

A good reason to consider the Twitter Stream API is stay under rate-limits imposed by Twitter on the Twitter REST and Search streams. Once you understand what each API does, the sky is your limit when it comes to interacting with users on Twitter. Obviously, the more creative Apps involve using two or more APIs in synchronization and doing something that really adds value to the business / end-user.

Categories: Web Tags: ,
Follow

Get every new post delivered to your Inbox.