Thursday 30 May 2013

What is AngularJs

AngularJS is a js framework developed by google. AngularJS is  100% JavaScript, 100% client side and compatible with both desktop and mobile browsers.

Angular can use jquery if it's present in your app. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQlite.

jQlite is a tiny, API-compatible subset of jQuery that allows Angular to manipulate the DOM. jqLite implements only the most commonly needed functionality within a very small footprint, so only a subset of the jQuery API - methods, arguments and invocation styles - are supported.

AngularJs and jquery embedded  Example:

 
function Controller($scope) {
                $scope.master= {};
                 $scope.friends = [{name: "test"},{name: "aest"},{name: "sest"},{name: "dest"}];
                $scope.update = function(user) {
                    $scope.master= angular.copy(user);
                };
                    $scope.addTodo = function() {
                  
                    if($('#numberId').val()==''){                     // Jquery Syntax and methods

                        $('#numberId').removeClass("ng-pristine ng-valid ng-valid-number ng-valid-max ng-valid-min");
                        $('#numberId').addClass("ng-valid-max ng-valid-min ng-dirty ng-invalid ng-invalid-number");
                    }else{
                        $('#frm1').submit();
                    }


             
   };

                $scope.reset = function() {
                    $scope.user = angular.copy($scope.master);
                };

                $scope.reset();
            }

Angular's jQuery lite provides the following methods:
Angular Js Vs jquery:

i) AngularJS is a  framework . JQuery is not a framework but a library.
ii) If you are looking to build a single page app especially a CRUD app then AngularJS is a good fit. Single page apps can be done using query as alone but you will have to manage the framework side of things yourself.

FAQ:

http://docs.angularjs.org/misc/faq

AngularJs Cheat Sheet


http://www.cheatography.com/proloser/cheat-sheets/angularjs/

Tuesday 28 May 2013

PHP Benchmark

Do you know when we are writing PHP code how much its impact on performance of  our program?
Are we aware the right way of writing  code which help to improve the execution time?
 How many times we are bother to use string in single ( ' ) quotes rather then double( " ) quotes just an example. There are many php methods we  using unknowingly which degrades performance of the application  due to higher execution time. Lets correct it now by follow the php benchmark


http://phpbench.com/

You probably already knew these, but a refresher is never worthless :-)

Sunday 20 January 2013

Simplest way of js validation using parsleyjs


Now forget about writing lengthy code for js validation use parsleyjs

http://parsleyjs.org/documentation.html

Enjoy !!!

Friday 31 August 2012

Garbage Collection in PHP

Today I was reading one article about how garbage collectors works in php and found its very useful.

Click here to read this article and share your experience with us.
  If any one found other good articles, i will be appreciating if you could share with us.


Wednesday 4 July 2012

How to Fetch Taxonomy Term in Drupal 7


Some time we not able to print value of taxonomy in *.tpl.php page. We can easily print value of a field.

Example

 <?php print $node->field_status_icon[$node->language][0]['value']; ?>

When we do same thing for taxonomy, we found blank content. For taxonomy we can fetch data through simple sql code.

Example

 <?php $result = db_query("select * from taxonomy_term_data where tid='".$node->field_type['und'][0]['tid']."'");
foreach($result as $record)
{
 echo $record->name;
}?>

Complete Code: 

Page—<page name> .tpl.php 

<div class="event_page_mid">
<div class="eventext" >
<?php if($node->field_type['und'][0]['tid']): ?>
<div class="field field-type-options-select field-field-type">
 <h3 class="field-label">Type</h3>
 <div class="field-items">
 <div class="field-item"><?php

 $result = db_query("select * from taxonomy_term_data where tid='".$node->field_type['und'][0]['tid']."'");
foreach($result as $record)
{
 echo $record->name;
}


?><?php //print $node->field_type['und'][0]['tid']; ?></div>
  </div>
</div>
<?php endif; ?>

<?php if($node->field_genre['und'][0]['tid']): ?>
<div class="field field-type-options-select field-field-type">
  <h3 class="field-label">Genre</h3>
  <div class="field-items">
      <div class="field-item">
      <?php

 $resultterm = db_query("select * from taxonomy_term_data where tid='".$node->field_genre['und'][0]['tid']."'");
foreach($resultterm  as $recordnew)
{
 echo $recordnew->name;
}


?>
      <?php //print $node->field_genre['und'][0]['tid']; ?></div>
  </div>
</div>
<?php endif; ?>

Monday 2 July 2012

How to Write Doctrine Query OR conditions

 

See how we can write doctrine query  using multiple OR conditions which will prevent you from the special characters.

Example: 
$query = Doctrine_Query::create()
        ->select('u.*, up.*')
        ->from('sfGuardUser u')
        ->leftJoin('u.Profile up');
        $query->where('u.username LIKE ? OR u.first_name LIKE ? OR u.last_name LIKE ? OR up.fullname LIKE ? OR u.email_address LIKE ? OR up.charity_name LIKE ? OR up.advertiser_name LIKE ? OR up.organization_name LIKE ?',
            array('%'.$input.'%', '%'.$input.'%', '%'.$input.'%', '%'.$input.'%', '%'.$input.'%','%'.$input.'%', '%'.$input.'%', '%'.$input.'%'));

Wednesday 13 June 2012

Magento robots.txt

Magento comes without robots.txt functionality. It can be useful to add one yourself to tell the search engines where they are not allowed to index. It will hide your javascript files, hide SID parameters and prevent some duplicate content. It will help your SEO process and reduces resources on your server. In this blogpost explain you how to set your own robots.txt using an existing example and using an extension. Both solutions are easy to handle. 

 Very good explanation :

http://www.byte.nl/blog/2012/06/11/magento-robots-txt/