Shaikh Sonny Aman’s Blog

Lets learn and share!

How to create polls with Polldaddy

Posted on | March 10, 2008 | No Comments

 So, you like have some polls showed up on your site? What should you do ? Design database, design the models and finally passing hours together with image processor to give a nice look.

There  is a easy solution offered by Polldaddy. Create an account instantly in polldaddy, create your poll. You can configure questions in various type including, single selection, multiple selection etc covering almost everything you will ever need.

Having configured the poll, polldaddy will give you a code, generally javascript. There is an option if you like a flash poll.

Paste the code where you need. Bingo !

Look at the following poll:

Javascript:



flash version:



By the way, you will have the polls with above options for FREE :).

PHP MVC Framework

Posted on | March 9, 2008 | 4 Comments

Its my dream to make a popular site. I was dreaming since long. But, all I know is java and .net, little perl. And unfortunately all the affordable and adorable hosting plans runs on PHP. A language which I used to like the least and knew almost nothing. Since I am now working on PHP and fortunately enough with close collaboration with Hasin Hayder, I am trying to put my dream in reality.

While making a website, first came in mind is which framework to use. I heard much about cakephp though from the beginning I did not like it for no reason. May be it seemed complex. Searching over the net, I came across PRADO and CodeIgnitor. I looked into these frameworks closely and went through their sources to understand how it works.

I liked prado as it has great similarity with apache struts framework for jsp. I quickly understood how to work with it. But I think the power of php is to being simple and straight. While prado certainly a good candidate for a well formed, nicely designed MVC framework, I do not often like the idea of writing custom component unless it is necessary. I love and used custom components in jsp i.e. jsp tag extensions, but I was doubtful on its necessity in php development.

Moreover, usually the front end is built by the UI guys. And most of the php sites are made targeted to the mass public, aesthetics plays a vital role in these sites. Now, writing such sites using prado may be troublesome. I personally had the experience to cut out the html codes and write into components in a mvc framework used in my office. IMHO, PRADO is best suited for software applications.

On the next day, I was astonished by the simplicity of the codeignitor. You could easily call a class member function trough a SEO friendly URL. CI could be easily used with rich UI made by the front end teams.

But, something was really bothering me, what MVC framework is practical in php arena? I am a new comer in PHP world with experience with some other frameworks in java, .net and ferite. Why not I start my own according to me need? Well, it may not be a success at the end but surely I will be able to learn much about php.

Join me with the journey in creating your own custom framework ? I will be needing your help :).

Recently, I became a member of orchid framework, another child of Hasin. I think my attachment to this project and building my own fw will help me contribute in both the fw. This fw seems promising(dont forget its father !) and very feature list. You are invited to be a part of us… have a try, I am sure it will taste good :)

CSS tab style submenu with jquery

Posted on | March 6, 2008 | 4 Comments

Undoubtedly CSS is a powerful way to produce lightweight and slick effects on web sites. Not only good look, enhanced usability can be achieved by using CSS at a very low bandwidth… you won’t need lotz of javascripts. But, to enable interactivity with the user, their should be some sort of scripting. Thats the role that can be performed by jQuery in some seconds.

I know, there are lots of example on the web on my post topic. There are also some those can used freely. Then what the heck I am wasting my time to invent the wheel again ? Actually I am not inventing the wheel, I will just create another wheel, hope thats not offend you as there are many brands of wheel in the market!

Anyhow, I am not making the wheel from scratch. I was stepped into http://homelesspixel.de/tabs/. There I likd the css tab menu, I was looking for something almost similar to that:

CSS Tab menu

Unfortunately, there was no way to change the menu items. So I added another submenu under a link and a css class “inv” which has its ‘visibility’ attribute set to ‘hidden’.

The menu structure is like this:

<ul id=”topnav”>
<li><a id=”a0″ href=”#”>Home</a></li>
……
<li><a id=”a4″ href=”#” class=”here”>Process</a>
<ul id=”subnav”>
<li><a href=”#”>Vision</a></li>
<li><a href=”#”>Team</a></li>
….
</ul>
</li>
<li><a id=”a5″ href=”#” >Expertise</a>
<ul id=”subnav”>
<li><a href=”#”>Vision</a></li>
<li><a href=”#”>Team</a></li>
…..
</ul>
</li>

</ul>

If an ‘a’ has the class ‘here’ , it is highlighted.

I updated the css to make all the subnav are invisible by adding ‘visibility’ attribute with ‘hidden’ value.

Now, comes the jQuery to play its role. Lets first define whats I am need to do:

  1. bind a function to ‘click’ event of the ‘a clicked.
  2. Remove highlight from all the ‘a’.
  3. Hide all the subnav’s.
  4. Set the currently clicked ‘a’ highlighted.
  5. Set its subnav visible.

Now, these steps are done in the following script:

$(document).ready(function()
{
$(’#topnav li > a’).bind(’click’, function()
{
$(’#topnav li > a’).removeClass(’here’);
$(’#topnav li > ul’).css(’visibility’,'hidden’);

$(this).addClass(’here’);$(’#topnav li > ul’).css(’visibility’,'visible’);

});
});
Bingo!!! Now I have my own tab style menu using CSS and jQuery.

Please feel free to use it if you ever need and do give your comment. I would really appreciate if you can show me a better way.

Good night.

RapidSVN + Meld = Painless versioning

Posted on | March 6, 2008 | 2 Comments

My last post was how to ease up with svn on GNU/Linux using a nautilus script similar to TortoiseSVN on windows. However, the script could not serve me up to my expectation when it comes to view the diff.

I have started using RapidSVN recently. I like its features and user friendliness.  Unfortunately, it has no built in diff tool. A diff tool must be specified in the Program form. This form can be invoked by following View->Preferences menu.

Kompare  with KDESvn was my last choice. This duo is also cool I admit but I am really a fan of Gnome :) Searching over the gnomefiles I reached to Meld Diff viewer. Moreover, synaptic repo in my Ubuntu 7.10 also listed it under development category.

Now, I can easily see the diff of a file against base or head or even with any version easily. Meld allows editing and saving both the files. Here is some screen shots:

Select versions for diffMeld in action

An Appraisal

Posted on | March 2, 2008 | No Comments

This post was actually done by Mukit Bhai on SQABD mailing list.

The following is an appraisal of an employee from his Project Leader…Read on…

Appraisal:

—————

Bob Smith, my assistant programmer, can always be found
hard at work in his cubicle. Bob works independently, without
wasting company time talking to colleagues. Bob never
thinks twice about assisting fellow employees, and he always
finishes given assignments on time. Often Bob takes extended
measures to complete his work, sometimes skipping coffee
breaks. Bob is a dedicated individual who has absolutely no
vanity in spite of his high accomplishments and profound
knowledge in his field. I firmly believe that Bob can be
classed as a high-calibre employee, the type w hich cannot be
dispensed with. Consequently, I duly recommend that Bob be
promoted to executive management, and a proposal will be
sent away as soon as possible.

Sd/-
Project Leader

THE FOLLOWING MEMO WAS SOON SENT FOLLOWING THE LETTER:
That stupid idiot was reading over my shoulder when I wrote
the report sent to you earlier today. Kindly read only the odd
lines 1,3,5,7,9,11,13 for my true assessment of him.

Regards,
Sd/-
Project Leader

The Mayonnaise Jar and 2 Cups of Coffee

Posted on | February 23, 2008 | 7 Comments

When things in your life seem almost too much to handle, when 24 hours in a day are not enough, remember the mayonnaise jar and the 2 cups of coffee.

A professor stood before his philosophy class and had some items in front of him. When the class began, he wordlessly picked up a very large and empty mayonnaise jar and proceeded to fill it with golf balls.

He then asked the students if the jar was full. They agreed that it was.

The professor then picked up a box of pebbles and poured them into the jar. He shook the jar lightly. The pebbles rolled into the open areas between the golf balls. He then asked the students again if the jar was full. They agreed it was.

The professor next picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else. He asked once more if the jar was full. The students responded with an unanimous “yes.”

The professor then produced two cups of coffee from under the table and poured the entire contents into the jar effectively filling the empty space between the sand. The students laughed.

“Now,” said the professor as the laughter subsided, “I want you to recognize that this jar represents your life. The golf balls are the important things—your family, your children, your health, your friends and your favorite passions—and if everything else was lost and only they remained, your life would still be full.”

“The pebbles are the other things that matter like your job, your house and your car. The sand is everything else—the small stuff. ”

“If you put the sand into the jar first,” he continued, “there is no room for the pebbles or the golf balls. The same goes for life. If you spend all your time and energy on the small stuff you will never have room for the things that are important to you. ”

“Pay attention to the things that are critical to your happiness. Spend time with your children. Spend time with your parents. Visit with grandparents. Take time to get medical checkups. Take your spouse out to dinner. Play another 18. There will always be time to clean the house and fix the disposal. Take care of the golf balls first—the things that really matter. Set your priorities. The rest is just sand.”

One of the students raised her hand and inquired what the coffee represented.

The professor smiled and said, “I’m glad you asked.” The coffee just shows you that no matter how full your life may seem, there’s always room for a couple of cups of coffee with a friend.”

Technorati:

Powered by Bleezer

Using fb:iframe

Posted on | February 20, 2008 | 4 Comments

I am totally new to facebook application development and taking help from resources available on facebook developers’ site at http://developers.facebook.com.

I planned to write down my problems and workout as I go through the journey in learning facebook application.

Now, I wanted to use fb:ifram. I plaved a test.php file echoes hello world on my application folder at my server and used the following code:

<fb:iframe src = “test.php” /> 

Ooops.. facebook wraped the output with facebook layout.

Now, on http://wiki.developers.facebook.com/index.php/Fb:iframe  it is written:

“You must use your server’s URL as the

src

for your iframe. Otherwise, apps.facebook.com wraps your page with the Facebook layout.”
Okey, I update the code :

<fb:iframe src = “www.myserver.com/myapp/test.php” />

Still, no luck.

Now, blindly added http:// at the beginning like

<fb:iframe src = “http://www.myserver.com/myapp/test.php” /> 

Bingo, now its working.

I think  “You must use your server’s URL as the

src

for your iframe”  is little bit ambiguous, it should inform that I must write the protocol i.e. “http://”.

Array operator overloading

Posted on | February 3, 2008 | 1 Comment

ArrayAccess interface is an excellent offer from PHP. Though I do not personally like the idea of operator overloading, this interface can be a great tool for developing application faster and neatly by overloading the array access.

The interface is to be implemented by a class and override the accessors methods.

Class diagram of ArrayAccess interface

I am giving a simple code that demonstrate its usage.

 class MyArray implements ArrayAccess {       
    private $arr = array();

    function offsetExists($name) {              
        return isset($name);
    }

    function offsetGet($name) {       
        return $arr[$name];
    }

    function offsetSet($key, $val) {       
        $arr[$key]=$val;
    }

    function offsetUnset($name) {       
        unset($arr[$name]);
    }
}
$arr = new MyArray();
$userMap["Hello"]="Worlds";
echo $userMap["Hello"];

This class can use a database for its model. The interface facilitates coding array style with similar __get() __set() functionalities for classes.

Btw, anybody knows how I can show codes like code in an editor with line number ?

PHP with NetBeans

Posted on | February 1, 2008 | 3 Comments

I am always a fan of Java. And like NetBeans as well. Though it used to be slow, but the latest release netbeans 6 is super fast, it may be due to the latest jre. Using the the latest jre, old java swing applications are now super fast!!! Believe me, better else try yourself. I am sure swing will come well into the desktop market in near future (it till then the desktop idea survives :P)

Anyway, I was searching for an IDE for PHP with auto completion feature. Having downloaded the netbeans6 I was surprise to find a plug-in named PHP! Downloaded it and got exactly what I was looking for :)
For more information visit Php plug-in for netbeans.

Agile mashup in practice

Posted on | January 22, 2008 | 1 Comment

“Traditional methodologies are a bunch of stick-in-the-muds who’d rather produce flawless documentation than a working system that meets business needs, Lightweight, er, ‘agile’ methodologists are a bunch of glorified hackers who are doing to be in for a heck of a surprise when they try to scale up their toys into enterprise-wide-software.”

– Jim Highsmith, in “Great methodologies Debate: Part 2″, Cutter IT journal

That says, none of the methodologies is perfect alone. Since traditional/formal models like Waterfall, Incremental,RAD model, Evolutionary, Spiral, Component-Based development etc are almost obsolete and impractical. They lost their feasibility in most cases for their time-consuming and expensive nature. Besides, few developers have the necessary background to apply formal methods, they often need extensive training on the model and methods. Furthermore, these models does not support a good communication with technically unsophisticated customers.

Hence come the agile methodologies. To produce the product right we encounter many implementation in this agile era, there are many paths originated from the agile development practice.

Now, which to choose ? Should you choose one and stick to that ? In my experience I found choosing a single methodologies is quite impractical, partly because none can match up with the unique project requirement, partly because there are way too many methodologies defined :P
Lets look at the core blocks of some major agile practices.

Extreme Programming (XP)
Planning:
Planning goes along with the creation of user stories. Stories are kept in index cards with priority value set by the customer. The xp team assigns a cost in terms of estimate time to complete. If the cost is more than three weeks, the story is broken into smaller ones. Needless to say, as agile goes, stories can be added any time!

Stories which will be included are set with customer’s approval along with the delevary date. The stories with highest value and the most risky ones are implemented first.

Project velocity:
Project velocity is calculated after each release. It is a simple calculation based on how many storeis are implemented in the release. Project velocity helps estimating the next release and understand the estimation accuracy.

Design and Spikes:
XP design provides only the implementation guidelines for a story as it is written. Specifying extra functionality is highly discouraged. Do only the things that is required for the current sotry in next release. If encountered a difficult design problem, create a spike solution i.e. an operational prototype.

One thing that you must need is the use of CRC cards. These cards also contains the release and story information. They are the only design artifacts produced by XP.

Coding:

Having done with the story and desing, now dive into development ? No, wait ! First write up some test cases and unit tests. Once the unit tests are created, focus only on what must be implemented. XP also encourages pair programing.

Testing:
As mentioned earlier,testing starts before coding. Tests should be done using a framework which will enable regression testing as the iteration goes on.

Adaptive software development(ASD)

It is based on team self-organization and collaboration. It is almost a formal incremental and iterative method which gives high value on learing practice.

Speculation:
First statge of ASD is speculation when the project goal, constraints etc are decided.

Collaboration:
Collaboration in this methodology does not mean simply being a motivated team working together. It is based on trust, the team met must trust each other to
1. Criticize without anmosity
2. Assist without resentment
3. Communicate to solve a problem

Learning:
Learning is practiced by formal technical review of the component built by the team members.
Read more

« go backkeep looking »