Posts

Executing a remote shell file from windows

Well... its something really simple but couldn't find the proper way to do. All I wanted to do is Running a batch script which will compile my codes and encapsulate in a zip file. Copy the zip file to a remote linux server. At the linux box, I need to deploy my application by unzipping the archieve And finally running other commands to manage something more. Problem was I was not sure about how to initiate a command in my linux box from windows batch script. Finally found  plink  with the help of  Mr.Yann Ramin  in stackOverFlow .  scp -p -pw password code-archieve.zip user@remote.host.com:/opt/code plink -pw password user@remote.host.com cd /home/user/Documents;./doTheJob.sh Here the plink is actually  logging in to the remote server Changing directory to where the script file resides [ cd /home/user/Documents ] running the shell script [ ./doTheJob.sh ] Note that how we are concatenating multiple shell commands in ...

Windows Tweaks: Adding commands with folder context menu

Command Prompt Here: In my development environment I need to access Command Prompt very frequently. And its really boring to open the console and every time do some cd.. cd.. cd and point it to my destined folder. You are feeling the same right? :) Just get it and enjoy it... Nothing much to do though... Just download the registry file . Then a “ Double click ”, followed by “ Yes ” and “ OK ”. And it will bring the command prompt in your folder's context menu. If you are using windows Vista or later, you already have this available. But now XP users will also avail the facility. Now, Just right click on any of your folder and click " Command Prompt Here ". The file is available through my Google doc shares. Download CMD_Here.reg .   Cruel Delete: Another utility here. Sometimes you may want to delete a large folder without being concerned about anything. All you want just to delete it. Then the command “ rmdir ” works much faster than window’s graphical delet...

Bada tutorial: Application basics

Image
Now as we know how to create a project and already met the containers , we can start writing our application right away. And for this we will need to have a little concept about some basics of starting up an application. So today's post is on some elementary stuffs. May seem little bit boring but yet required!!  I will not repeat the words already said in bada API doc. I put the links of API doc with each description. Please read the doc and find some additional concerns in this post. First lets look at the following state diagram of an application.  Fig: Application life cycle. Collected from bada API doc. You probably already have seen this earlier. To start with an application we need to know exactly how to handle all the methods indicated in the diagram. Lets start with the first one... OnAppInitializing: At the time of launching your application the system will call OnAppInitializing method to initialize it. Take a look at the bada API doc for this...

Bada tutorial: Meet the Containers

Image
Hmm... "Meet the Container !" :O What will be going on today!! :) Yes, today we will be looking on to all the containers. Because whatever application you develop you must need to deal with various types of containers. After all containers are the things that will hold all our component and show those on the screen.  Lets look at the following picture.  A total black window and a button saying "OK". At first lets find out how many components are there. What do you say? Well would you say like following? A dark black window. A button. is there anything else? Ok, lets look at the following one: ( Focus on "Frame" and "Form" only ) So you identified the "Frame" and "Form", right ? ( encircled ).  Yes these two are the most common companion for any BADA app developer. As you can see, your application must have a (only one) Frame on the very base. And then you need Form . An application can have multiple forms . Say yo...

Samsung BADA, Starting with sample application

Image
Hurrayh!! You downloaded all the required stuffs right? ( Didnt get my point :( ? Please refer to the earlier post  ;) .  Hope you already installed the IDE with language packs. If so just run the IDE. Specify your BADA workspace where all your projects are supposed be resided. And continue... So! Now we are totally ready to go for the sample applications right? Its really easy and fun at the same time. Hope the BADA IDE is running behind your web browser. Now all you need to do is follow the steps given here to run some sample applications. Playing with these applications will make you familiar with this IDE, as well as give you a brief idea over the BADA SDK. Anyway, lets stop my tattling and start working. 1. Open the window of BADA SDK samples window. Go to “Window > Show view > Other”. This will show you a dialog like following. Select Bada SDK samples from this dialog. Click OK. The window of sample application list is opened. 2. Right click on any applica...

Samsung BADA, A new era of Samsung smart phones begins

Image
Yes! Samsung presenting a new mobile OS for the smart phones. This is BADA. You can take a look at the press release of BADA . This one is developed on top of the Samsung's legacy operating systems, but with a target for providing high end smart phone features. Besides, this is open for developers in the whole world. Just register in developer.bada.com and get joined with BADA community. Develop your smart application for your Samsung Smart phones and let others have fun with the excellent BADA applications. As I am developing BADA applications, I will try to keep a focus on BADA app development in my following series of blogs. Today here is a very basic introduction with BADA. So lets start... Start with the community: Here is the BADA developer website (  http://developer.bada.com ). Register there and get connected with lots of resources on BADA and also find very active BADA forums to share your learnings, problems, suggestions and recommendations. Find the forums here...

HTML 5, a complete guideline to startup

Image
Today I was rambling in my web world on HTML 5 . Wondering about the great features offered. I think you also would like to start working on HTML 5 right now. So here are few things that will help to boost up your learning over this. http://diveintohtml5.org/ . [A detail discussion over HTML 5 with lots of techniques for diagnosis] http://diveintohtml5.org/introduction.html . [Have an basic idea] http://diveintohtml5.org/detect.html . [Learn the techniques for detecting supports from your browser for HTML 5] http://diveintohtml5.org/canvas.html . [ Meet the canvas of HTML 5 ] http://diveintohtml5.org/storage.html#methods . [The local storage provided by HTML 5]. See also  storage.html#halma ,  storage.html#future http://diveintohtml5.org/forms.html . [Form elements are having more comprehensive options. See the iPhone web browser trick for a usability] Here is  all available tags  in a glance. Take preview on HTML 5 here. http://html5demos.com/ . [...

Try the "try" method and get rescued

Have you ever used 'try' method in Ruby on Rails ( yes it is provided by rails not ruby ). I started loving this method so much. As the method name implies you will try to do something. If anyhow it fails it doesnt get fired on you by throwing any ugly exceptions. Look at the documentation . You may have already guessed the idea. But still lets work with a simple example. User.admins.first.try(:address).try(:reset) instead of User.admins.first.address.reset Here we are finding the first admin. Then accessing his/her address and then try to reset it. But what if that admin doesnt really have any address. I mean User.admins.first.address.first.address is nil. Then a NoMethodError for nil class would be waiting for you. But with the try you are safe. WHY? Actually try does nothing but invoking the Object#send method with the function name and the passed parameters. You can even pass a block through try. And apart from this Object#try method, you will have a N...

Highcharts for Agile development

Image
Did you ever try Highcharts for showing any kind chart data in your web application? Its great! Recently they released a newer version with lot more performance improvement and new features. Im talking about the version 2.0.0. Find it at http://www.highcharts.com/download . By the time you are reading this article if you find more upgraded version of highcharts, then of course it will be of more fun. Share it through comments :D Courtesy by Highcharts.com Just look at the Demo page of it. You will find lots of different kind of charts over there. Choose anyone according to your need. The first reason why I like Highchart is it totally based on javascript. Earlier I used openflash chart(OFC)  which is really slow by its process of data showing. As OFC is based on flash, you will need the flash embed code first, then this flash code will request for the data to your server and then it will show the chart. Maladroit huh !! But here with the help of Highcharts you will be...

Design Pattern in Ruby 1: Decorator pattern

Image
Decorator pattern , something that gives you two type of things A plain vanilla cake and  Cream, cheery etc to decorate the cake :D How does it sounds? Mouth watering design pattern right? Anyway, dont get too excited!! we're gonna dive into the code shortly 8( You might have already known all the nuts and bolts about this pattern, but I was really wondering about the implementation of this pattern in Ruby.  Here I will work with the example given in Head first design patterns (Chapter 3) . There they gave the example of a coffee house. Like our plain vanilla cake, the coffee house also have two different type of things: Beverages: HouseBlend, DarkRoast, Espresso and Decaf Condiments: Milk, Mocha, Soy and Whip So that you can have a DarkRoast with some Mocha and Soy :) However, I think we should have a look at the class diagram first Notice that, here all concrete beverages are inherited from the abstract class Beverage . And all concrete cond...

Shoulda test macro for acts_as_state_machine

In this post I will talk about shoulda macro for state_machine to facilitate TDD. So lets get familiar with these at first (want to skip the intro! ok, just  jump to code  ;) Acts_as_state_machine : A really powerful plugin to incorporate state machine in rails application. In scrumpad we are using this plugin and it made the implementation such a fun that everyone here just love to take this work 8). You can  take a look  to see how this plugin makes everything for you in a blink of eye. Shoulda : "The Shoulda gem makes it easy to write elegant, understandable, and maintainable Ruby tests"- Thoughtbot Community . Yes, shoulda really makes your test codes speak. You will be able to define your every test cases exactly in the way that you would probably state to someone. TDD : Firstly programming without test code, impossible!! And, if your application is written in any dynamic language(e.g: ruby, php) then TDD is the must. In TDD practice at first you...

Selenium RC 1.0.1 with Firefox 3.6

The last day I get stuck while I was writing my automated test codes with selenium but using firefox 3.6 . Selenium was failing to open the firefox browser session because selenium RC 1.0.1 does not support firefox 3.6 by default. You know what I did? I did nothing but some googling as everyone does :) and found an excellent post on describing this problem. Here it is [ http://www.qaautomation.net/?p=15 ]. Well you will have a lot of commands to read there. But in a nutshell all you need to do is modify the firefox version in following 5 files in the selenium-server.jar archive. ./customProfileDirCUSTFF/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf ./customProfileDirCUSTFF/extensions/readystate@openqa.org/install.rdf ./customProfileDirCUSTFFCHROME/extensions/{503A0CD4-EDC8-489b-853B-19E0BAA8F0A4}/install.rdf ./customProfileDirCUSTFFCHROME/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf ./customProfileDirCUSTFFCHROME/extensions/readystate@openqa.org/...

Writing test code for ApplicationController

Did you ever try to write functional test code for ApplicationController? You might have faced such situations where you needed to test some methods of your application controller. Well when you will start testing a method of your ApplicationController, you would probably have a "aha" moment - "If I had a view file for that method!!". Yes the problem is template missing error.  Usually the methods in ApplicationController dont have a corresponding template. Therefore, sending test request to those methods will definitely raise an ActionView::MissingTemplate error. So what you need to do is just tell the ApplicationController - "Please dont raise any template missing exception. I am testing your methods :)". But how will you tell this? Simple, just override the rescue_action method and raise nothing!! Just like the following: class ApplicationController def rescue_action(e) end end Yes, this will keep all the exceptions away from you. Howev...

Content publish in blogspot through google docs

Today was an amazing day!! Feeling like flying in sky after a long time of heavy working pressure. Rambling around the web, chatting with friends, commenting pictures in facebook etc... in a nutshell enjoying the time very much.  Suddenly I found this web site  http://www.ismckenzie.com/blog-writing-software/  ( I was googling a easy way to publish content in my blogs with source code). One word stuck my eyes "Google docs". Personally i like it very much. I maintain all my TODOs, presentations, daily calculations in my google docs. And when i saw that it also facilitates to publish my content in my blog i was so excited the check it out instantly. However I configured my blog in Google docs account and trying to publish the content in my blog. As i also needed to publish source codes in my blogs lets try to put some code also. dont know what will happen :P i=0; [1,2,3].each{|i| i};  puts i; simple ruby code. Well after writing the code here I opened thi...

Margin 0 auto in Internet Explorer

I dont know how I missed this fix(!) of so common problem for these long days. Whenever I started some template related work i found IE the most irritating. What I am talking about is using Margin: 0 auto, mostly used to center a container ( DIV or table anything ). But before few days ago I believed that IE is not gonna support this easy way and i must have to write some additional IE fixing in my css files. However now i got to know that the DOCTYPE type declaration is the thing I was using incorrectly. As soon as I fixed my DOCTYPE declarations the IE started working perfectly. However in a nutshell it is really a better practice to use proper DOCTYPE in your web applications. Please refer to the wiki for detail understanding of using DOCTYPE. Here I am giving a code snap. Just run it in your IE with and without the DOCTYPE declaration at top and watch out the differences. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1...

Javascript minification along with automated deployment

Javascript compression has always been a great concern specially for interactive web applications where you will have lot of javascripts with lot of ajax requests. And as the ultimate target is to make your user happy with faster response, its better to squeeze your javascript files as much as possible. If possible reduce the number of files as well. Lots of advices are available to make your web sites faster enough as if users are working in desktop application. A good guideline can be found here . Besides we also need such a convenient way so that we can have this minification process as a part of our deployment. Some kind of automation I meant. Well we have found JS min very useful regarding all the above concerns. It gives pretty much good ratio of compression for js files compare to some contemporary minification processes. And in ruby you will have a rake task to make the minification process totally automated. In scrumpad we used JS-min with little bit tweaked. Here I wil...

Retina pattern recognition towards human identification

Image
A paper prepared from my undergraduate thesis work has been indexed in IEEE Explore recently. Find the abstract at IEEE explore . It was basically on human identification based on retina blood vessel orientation pattern recognition. We proposed a way to detect the pattern of the blood vessels followed by identifying the intersection points of those vessels. Blood vessel orientation of different human beings are different and hence the intersecting points of these vessels give a unique pattern to recognize. However, to compare between two patterns, the variance of the intersecting points are measured. If the measured variance is under a threshold value which is empirically determined, we assume it as a match. Steps are pictorially described below: 1. Human Retina: Green-Scale version of a colorful retina image 2. Segmentized blood vessels: Binary image. Detected blood vessel portions are black 3. Intersecting points detection (Binary Image): Binary image. Inter...

recognize_path to determine url hash from RESTful url

If you are using RESTful controllers for your application, same url can refer different actions in a controller based on the associated HTTP method. For instance let’s consider a URL http://your.host.com/messages/123 . Any request with this url with HTTP get will be paired with the show method of messages controller. Some other pairs are like HTTP put with update action, and HTTP delete with destroy action. Then how can you get a hash of controller and action from this url? In this situation recognize_path to the rescue. You can use ActionController::Routing::Routes .recognize_path(url, method) where url is the '/messages/123' part and method is anyone from GET, PUT, POST or DELETE. It will return a hash containning controller, action and other parameters, for example :id => 123 in the above case. By the way if you are thinking to trim the first part of the url just use as following url = 'http://your.host.com/messages/123' extracted_part = url.g...

ROR draggable_element with ghosting property in IE

Some days ago I faced a problem of drag and drop functionality in developing Scrumpad . We had to give a way to drag a DIV element from one block and drop to another to make user experience more interactive. It’s really an easy task as we have many rich javascript libraries. Besides ROR provide a rich javascript helper. However we enabled the DIV s to be draggable by the following way: <%= draggable_element ‘element_[id]’, :revert=>true, :ghosting => true -%> Here ‘element_[id]’ refers to some DIV s having id like ‘element_1’, ‘element_2’ and so on... When equipped with everything I checked in firefox and found everything working well. But in IE this code created a huge mess. After digging a bit more I found the problem in the ghosting property in draggable_element function. Actually this property helps to create a replica of the dragging element and move that DIV anywhere else. But IE showed so devotion on it that it was creating a new replica on each movement of ...

Ajax form submission with tiny MCE editor

Hi, I was working with a Ajax form submission where the form contains a tinyMCE wrapped textarea. I was using prototype library for Ajax. Problem is when I called Form.serialize('form_id') , it couldn't retrieve the value of the textarea as it is wrapped by tinyMCE. At last I got a solution by just calling a tinyMCE method before the Ajax operation. Here is the stepwise detail: 1. My tiny MCE declaration was very simple like: <script type="text/javascript" language="Javascript"> tinyMCE.init({ theme:"simple", mode:"exact", elements:"desc" }); </script> 2. Following is my HTML form: <form onsubmit="return processForm()" name="submitForm" id="submitForm" method="post" action="request.php"> <label for="name">Name: </label><br /> <input type="text" name="name" i...