Friday, December 9, 2011

Movie Catalog Application

Created a Cross-Platform Movie Catalog application using Java, Swing and Mysql. Feel free to download and use it for your personal use. If you find any bugs, please post it as comment.

P.S. Set your mysql username as 'root' with empty password

Download File

Wednesday, February 23, 2011

Setting up Flex on Eclipse for Linux

For Long time I'm looking to switch over to Ubuntu, my favorite OS., but due to unavailability of flex builder for Linux I wasn't able to. Later after a long Google search, I came across following post by Nicholas, http://tboxmy.blogspot.com/2010/10/setting-up-flex-on-eclipse-for-linux.html.




Pre-installation checks: Have you installed Eclipse 3.5+ and Java Development Kit 1.5+

Step 1. Download the fb4linux files in 4 parts from http://code.google.com/p/fb4linux/downloads/list

  • FB4Linuxaa
  • FB4Linuxab
  • FB4Linuxac
  • FB4Linuxad
Merge them together into a BZIP2 format and extract using the command prompt at the terminal. At the folder where you downloaded the 4 files, just type

cat FB4Linux* >FB4Linux.tar.bz2
bunzip2 FB4Linux.tar.bz2
tar -xvf FB4Linux.tar

I renamed the folder to Adobe_Flash_Builder4 since I did not want spaces between the folder name.

Step 2. Download the eclipse plugin for FB4Linux from http://www.brighthub.com/hubfolio/matthew-casperson/media/p/78806.aspx

Unzip the file ecplise and copy the plugins to /usr/lib/eclipse/plugins

The plugins are;
com.adobe.coldfusion.rds.client_1.0.266425.jar
javax.wsdl_1.6.2.v200806030405.jar
org.apache.commons.lang_2.3.0.v200803061910.jar
org.apache.xerces_2.8.0.v200803070308.jar
org.apache.xml.resolver_1.1.0.v200806030311.jar

Step 3. Start Eclipse and apply the plugins.

In Eclipse select Window->Preferences->General->Capabilities and make sure that the Classic Update option is checked.
Click Help->Software Updates->New Feature to Install.
Click the New Local Site button, and type in the location where you extracted FB4Linux in step 1 (you will need to specify the eclipse subdirectory to be specific).
With the Adobe Flash Builder 4 site selected, click the Finish button. You will be asked which features to install. Tick the Adobe Flash Builder 4 feature and click Next.
Accept the terms and click the Next button and click Finish button.

Restart Eclipse.

Step 4: Install the Flex SDK from http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4
Download and extract a copy of the Flex SDK from Adobe into a folder flex4.1.0

Set Eclipse to use the Flex SDK by right clicking on your Flash project and selecting Properties. Select the ActionScript Compiler option.
Click the Add button to add the location of the Flex SDK you have extracted.


After getting everything done, I found difficult set debugging of flex code. Then I got help from Arul Raj in http://www.arulraj.net/2010/08/flash-player-debugger-in-ubuntu.html


Here the steps for how to install debug flashplayer in ubuntu 10.04 firefox 3.6.
Steps:
  • Download the debugger version from here . Or Download this Zip file for Linux http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_plugin_debug.tar.gz
  • Extract that zip file and get that “libflashplayer.so”
  • Goto this folder “/usr/lib/mozilla/plugins” then copy and  paste that libflashplayer.so here. Then Delete the shortcut named “flashplugin-alternative.so”
  • Create a mm.cfg file in your home directory. For example /home//mm.cfg
  • The mm.cfg file is look like the below
ErrorReportingEnable=0
TraceOutputFileEnable=1
MaxWarnings=0
Then restart your firefox.


After all this, my flex web application runs smoothly in linux. But when I try to run a AIR application, got the error, "! ApolloLaunchDelegate.dirDoesNotExist!". Then I got reference from, zrong's Blog, http://zengrong.net/post/1024.htm 


The reason is downloaded from the opensource.adobe.com FlexSDK does not include Linux compiler, you must use the Linux version of the AIR SDK. 
According to their needs and install the AIR runtime version, from the following link to download: 
AIR SDK 2 
Unzip the downloaded content and coverage to your Flex SDKS folder. 
At the same time, should be installed AIR Runtime .





Thanks for the people who helped me in this process.. Long life bloggers..

Thursday, April 22, 2010

GridFS in MongoDB

I was trying to store files in MongoDB. As was new to MongoDB, I had to seek help from Google. Finally, I came to know about GridFS and GridStore. Gave a kick start to them and worked out some samples using GridStore.

To my surprise I found out that GrisdFS using two collections, viz., files and chunks which was completely unfamiliar. After digging deep I came to know that files are one that contains the actual data and the chunks are the one that contains the binary chunks of that file. Each file stored will have a unique file ID.


To store a file using GridStore,



To retrieve a file using GridStore

Having  toiled away in getting this through all day, I was relaxing by browsing  more on GridStore to my surprise, fortunately or unfortunately I came to know that the GridStore is deprecated from driver version 0.19. GridStore was replaced by two new classes, viz., Grid and GridFileSystem.

Grid allows you to store and retrieve files using unique ID and GridFileSystem uses the filename.

File operations using Grid


File operations using GridFileSystem

Eventually, I found it really coooooool.

Friday, March 26, 2010

MapReduce - Really reduces!

Look at the image below
Image and video hosting by TinyPic

Yes, absolutely they are the labels of the blog posts. Do you have any idea how the labels are grouped together along with their counts? Which is commonly known as batch manipulation and aggregation of data.

If I'm a relational database user my answer would be like this,
  • Have a table for tags.

  • Have a table for posts.

  • Associate the related tags to the posts.

  • Do some complex queries using 'GROUP BY' to fetch the tags and their counts.

But in the case of document oriented database like MongoDB, the tags will be stored as a String Array inside each post object. For example a post objects will look like





As you see, tags are not related to each other and two post objects can have redundant tags but, how do we group these tags?

It is a piece of cake through a tool called MapReduce. As the name indicates this includes two functions, Map and Reduce. To simplify we can say as,


Map function - emits each tag as a key, value pair.




In the above snippet, this refers to the current post object and the tags refers to the array of tags for that post.

Reduce function - receives the key and the value array, reduces the received values and eventually returns the result.







For more detailed info about these functions have a look at http://www.mongodb.org/display/DOCS/MapReduce.

Now let us see a sample code for illustration. The scenario is the same, there will be list of tasks and each task will have n number of tags and we have to group these tags with their count.

My tasks collection will look like the snippet below




The MapReduce class is written as,




Note : Here I had used MongoMapper, Mongo ORM for Ruby. To know more about MongoMapper, visit http://mongomapper.com/

You can also use, db = Mongo::Connection.new("localhost", 27017).db("mydb")

Used this Class to mapReduce tags as



Wednesday, March 24, 2010

Kick Start

This is my first blog. Here I want to share the reason which pulled me to write blog. I used to update myself with the latest technologies (TechGraze!) and while doing so I found a fact that most of the perfect solutions I got were only through various blogs than documentations. Hence with the motivation of my colleagues, I thought of blogging the new things I learn and I use, though it may be a simple thought or information.

I started working on Ruby and MongoDB only a month ago, they sound like Greek and Latin to me at first. But when get started, I find them amazing. Previously I used to develop web applications using Java and MySQL. But I find Ruby more simpler and easier than Java. The most important fact is that the development speed in Ruby is awesome.


Most of the people think that the databases are always meant to be relational, even I was thinking the same a month ago but now things have changed. Introduction to MongoDB had changed my views towards databases. Document oriented database structure is something new for me and weird when I heard first. But when I started using it, I found it more simple and I jus WOW. No need for lengthy sql queries. For instance, instead of "select *" query we can use "find()".

I find myself very interested and enthusiastic in learning these technologies which are completely new for me. I used to love Java but "I got a better girl"!