28 Feb

Killer Applications with CakePHP, JQuery and Adobe Air

CakePHP, Latest Developments, jQuery

Have you ever wished to program desktop applications for your own web app? If you are like me, that is, most of the lazy web programmers… you never put your hands on any desktop language. Even though all of us knows what flexibility can be given to a web app if we develop its desktop based client.

I came across a new development framework, Adobe AIR, which lets you build cool desktop based application simply with web technologies. If you are good at HTML and AJAX you can easily start with this new framework. I was surprised to see that there are so many applications already using this. After just 3 hrs of experimentation with this, I started loving this new tool. It is very cool. Some advantages which impressed me are:

  • Real Fast: I built a stock market monitoring tool in just 3 hrs. It didn't look like I had to learn something new, everything went smooth. It was like developing AJAX enabled HTML pages and testing them in browser. Once you're done, you simply create xml configuration files, copy a JS from framework, compile it, and you're done.
  • Use your favorite JS Library: This is an amazing feature. My personal favorite is JQuery and I use it in almost every project. Please note: you have to have the latest version of JQuery to get it working with Adobe AIR. They recently patched for Adobe AIR only. I already wasted 30 minutes in solving security issues.
  • Cool CSS Extensions: Check this out.
  • Easy Debugging: Any errors/exceptions appear in command window.
  • Easy Drag and Drop: Super-easy functions like dragstart, drag, dragend, dragenter, dragover, dragleave, and drop.

Check out my stock market tool, just a basic version:

Everything is linked to a backend application which runs on CakePHP. Login function (UsersController::login) returns session_key to the desktop application if login is successful.

JavaScript:
  1. function process_login()<br />
  2. {<br />
  3. $("#status").html("Logging in...");<br />
  4. user=$('#user').attr('value');<br />
  5. pass=$('#pass').attr('value');<br />
  6. $.get("http://localhost/StockBack/users/login/"+user+"/"+pass, function(session_key){<br />
  7. if(session_key=='false')<br />
  8. {<br />
  9. $("#status").html("Unable to login");<br />
  10. }<br />
  11. else<br />
  12. {<br />
  13. $("#status").html("Logged in successfully");<br />
  14. $("#login").hide("slow");<br />
  15. $("#panel").show("slow");<br />
  16. }<br />
  17. });<br />
  18. }

(Sorry for posting code like this but my code editor in wordpress sucks – if anyone knows a good one, please recommend me)

To start learning, some important links are:

Developing Adobe AIR Applications with HTML and Ajax

Adobe AIR Quick Starts for HTML

Adobe AIR Language Reference for HTML Developers

The Adobe AIR HTML documentation set (a ZIP file) is available for download here:

http://www.adobe.com/go/learn_air_html_docs

11 Feb

Business Processes using Artificial Intelligence

Best Practices, Latest Developments

Business growth and expansion is in every entrepreneur’s soul. Most of them come out with good ideas and suggestions to grow their businesses, but in today’s competitive world, one can not rely on man to perform all the tasks. Automation of the industries is a very genuine step to fulfill the dreams of expansion of the business. I have seen numerous cases, where the business, with lot of help from automation, grows at a very fast pace.

The automated industries are getting the fruits, in a long term, in following ways

• Time saving
• Higher Efficiency
• No human error
• Low operational cost

The use of artificial intelligence is one of the most unconventional thought in today’s world. Artificial Intelligence leads the industry to get the boom in production and output is maximized in least inputs.

The cases of automation can be seen in today’s world in most reputed organizations. We recently helped a data entry company, in automating their data entry process. Before automation, they faced lots of problems with the human errors, low efficiency, high operating costs, in form of salaries. The pitfall deteriorates the working conditions and leads the organization into defalcation.

We came up with an excellent idea to import the concept of artificial intelligence by the means of automating the data entry process and achieved the output by 10 times with no extra costs and no labor costs.

Another case of artificial intelligence is used in Maruti Udyog Pvt Ltd, for providing the colors to the body parts with help of robotic arms. This provides the uniform color to the body parts and a higher quality has been achieved in it.

Artificial Intelligence is now days used in many companies and all of them are diverting their processes to make the best output and hence, best profits.

The concept will rock the world with its leverage and provide large profits to entrepreneurs in all perspectives. The pros of the process are much higher than the cons. The only limitation in the process is its high initial cost.

“The greatest obstacle to discovery is not ignorance - it is the illusion of knowledge”. Daniel J Boorstin.

The quote explains the whole dilemma of the today market growth, where we are running behind every illusionary idea to get the success without seeking for the available option in form of Artificial Intelligence.

- Sandeep Sinha

11 Dec

A better way to send emails than CakePHP’s default Email Component ?

Best Practices, CakePHP, Latest Developments

While working on a big project today, I had to use this default Email component. I was disappointed when I had to create two views for every singly mail... This is really bugging.. Plus, It is not fast as it can be.
At the same time, I've always loved the magic Model functions: findAllby

Today, I realized how productive it would make us if there's some similar magic functions for email as well. Say to send a user approval letter, you just have to write following in your controllers:

PHP:
  1. $this->Email->send_UserApproval($email, $verification_code)// to send user approval mail
  2. $this->Email->send_UserWelcome($email)//welcome mail
  3. $this->Email->send_AdminPaymentNotification($from);   // payment notification to admin

This does not only increases the speed of writing code, but also makes code look beautiful.

While I was thinking about the idea, I dugg into model class of CakePHP to find how its done, I found the source of magic:

PHP:
  1. function __call($method, $params, &$return) {
  2. $db =& ConnectionManager::getDataSource($this->useDbConfig);
  3. $return = $db->query($method, $params, $this);
  4. if (isset($this->__backAssociation)) {
  5. $this->__resetAssociations();
  6. }
  7. return true;
  8. }

This is the function which creates all Model:findAllby functions. So I decided to write my own component which will definately save time in many of the projects.

One good way of developing this would be creating a language/email file like emails.php with something like this:

PHP:
  1. 'user'=>array(
  2. 'Approval'=>'Hi user, You are about to get approved.',
  3. 'Welcome'=>'Welcome user, you can now play with our system.'
  4.  
  5. ),

This file will be read by Email::__call() and our magic functions will be created on the run.

What do you think of this method ? Is it better than current Email component ? I'll blog again as soon as my email component is ready..