Showing posts from 2016

How to show Loader for $http calls in AngularJs ?

Hello Readers !!  In this post we are going to see how we can add a loader for $http calls in our angular applications. This loader will be shown whenever our angular application will send some call to server. I am assuming that you are aware of basics of AngularJs,  if not then please go through the AngularJs official Developer Documentation. So, lets begin, first of all we will be making simple loader UI with HTML and CSS . So our HTML will look somewhat as shown below. <div id="loader" class="loader" loading> <span class="fa fa-spinner fa-pulse fa-2x fa-fw loader-align"></span></div> Here I have used font-awsome’s spinner icon . You can keep same or can build your own loader/spinner, somewhat like this . Now let’s move to CSS part. Our loader should cover whole area of page and should not allow any actions unless all calls to server are finish. All we need to have div which will be having height and width 100% and z-inde

What is IP address "overlapping" within the context of NAT ?

IP address overlapping refers to a situation where two locations that want to interconnect are both using the same IP address scheme. This is not an unusual occurrence; it often happens when companies merge or are acquired. Without special support, the two locations will not be able to connect and establish sessions. The overlapped IP address can be a public address assigned to another company, a private address assigned to another company, or can come from the range of private addresses as defined in RFC 1918 . Private IP addresses are unroutable and require NAT translations to allow connections to the outside world. The solution involves intercepting Domain Name System (DNS) name-query responses from the outside to the inside, setting up a translation for the outside address, and fixing up the DNS response before forwarding it to the inside host. A DNS server is required to be involved on both sides of the NAT device to resolve users wanting to have connection between both networks.

What is Service Provider PAT Port Allocation Enhancement for RTP and RTCP?

The Service Provider PAT Port Allocation Enhancement for RTP and RTCP feature ensures that for SIP, H.323, and Skinny voice calls. The port numbers used for RTP streams are even port numbers and the RTCP streams are the next subsequent odd port number. The port number is translated to a number within the range specified conforming to RFC-1889. A call with a port number within the range will result in a PAT translation to another port number within this range. Likewise, a PAT translation for a port number outside this range will not result in a translation to a number within the given range.

How to setup xdebug with Netbeans on Unbuntu

xdebug is a PHP extension for debugging of php code. It supports stack and function traces, profiling information and memory allocation and script execution analysis. It uses the DBGp debugging protocol.  In this post we are going to see easy steps to install and setup it with Netbeans IDE on Ubuntu Step 1: Install xdebug using following command sudo apt-get install php5-xdebug   Step 2: Browse to your php folder and locate file. In my case it is /usr/lib/php5/20121212/ . Copy this files path. Step 3: Open your php.ini ( /etc/php5/apache2/php.ini ) and add following lines at the end of this file [xdebug]zend_extension="/usr/lib/php5/20121212/"xdebug.remote_enable=1xdebug.remote_autostart=1xdebug.profilerenable=1xdebug.remote_handler=dbgpxdebug.idkey="netbeans-xdebug"xdebug.remote_mode=reqxdebug.remote_host= Replace zend_extension path with the path you have copied in previous step Step 4: Restart your

Security Features in AngularJs

  One of the major concerns with any new technologies is security. They might introduce security holes into an organization’s IT infrastructure. But if you are using AngualarJs then this concern isn’t very severe. Securing an AngularJS application is as simple as enforcing the good security practices for any web-application. In this post I am going to take you through built in security features in AngularJs that you should keep in mind as you build your application. I will be also updating this post time to time whenever I got something new about Security in AngularJs . So lets begin with AngularJS security features one by one.  1. Expression Sandboxing AngularJS’s expressions are sandboxed, this means AngularJs restricts the expression from evaluating unsafe expressions. These can attempt to access the Function constructor, window object, DOM element, global variables, or the Object constructor. With these restrictions, all an attacker can do is execute a mathematical function, cal

PHP Script to scan all ports of website or host

Following is PHP code which will scan all ports of particular host / website and will print list of all open ports in result. This code can be use to probe a server or host for open ports. This is often used by administrators to verify security policies of their networks and by attackers to identify services running on a host and exploit vulnerabilities. ports scanning   is a process that sends client requests to a range of server port addresses on a host, with the goal of finding an active port; this is not a nefarious process in and of itself. The majority of uses of a port scan are not attacks, but rather simple probes to determine services available on a remote machine. So I will recommend to use it for making your servers more secure. <?php$host = '';for ($i=0; $i<=9999; $i++){ $connection = @fsockopen($host, $i); if (is_resource($connection)) { echo '<h2>' . $host . ':' . $i . ' ' . '(' . getservbypo

AngularJS router to use different template for Mobile and Desktop

In your AngularJS application, if you want to use different templates/views for mobile and desktop users then following script may be useful for you. What we have done here is, just wrote a function named as “_isNotMobile”. This function will return true/false by checking user agent of device. And also we have used that function inside AngularJs app’s router, before actually specifying template/view paths and that’s it! Simple! pla'use strict';angular.module('MyApp', []).config(function($routeProvider) {var _isNotMobile = (function() {var check = false;(function(a) {if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca

CRUD Operations on JSON object using AngularJs

AngularJS is a powerful JavaScript Framework. It is used in Single Page Application (SPA) projects. It extends HTML DOM with additional attributes and makes it more responsive to user actions. AngularJS is open source, completely free, and used by thousands of developers around the world. In this post we are going to see the code for how we can perform CRUD (Create, Read, Update, Delete) operations on JSON object. <!doctype html><html> <head> <title>CRUD OPERATIONS</title> <script src = "../js/angular.js"></script> <script> var myApp = angular.module("myapp", []); myApp.controller("tableController", function ($scope) { $scope.dataset = [{name: "shubham", email: ""}, {name: "sagar", email: ""} ]; $scope.newname = "test&quo

How to check if jQuery is already loaded in Magento

If you are building some custom extension for Magento and your extension includes jQuery, but you don’t want to load it if its already loaded by some other Magento extension or theme, then you can do so using your layout XML file as shown below. Here we are checking for the global window.jQuery variable. If that is undefined jQuery is not loaded yet. Add the following to your modules layout XML. <default> <reference name="head"> <block type="core/text" name="jquery_load"> <action method="setText"><text><![CDATA[if (!!!window.jQuery){ document.write('<script type="text/javascript" src="url/to/jquery/file.js"></script>');}]]></text></action> </block> </reference></default> This will be included in the head after all other javascripts are loaded and you can be sure jQuery wasn’t included if its already there.

PHP code for removing unnecessary whitespaces from html

Removing unnecessary white-spaces and extra characters from html source code, helps for improving overall rendering speed of web page. Specially in browser window. Following is simple PHP script which will remove all unnecessary white-spaces from html source. And thus minify it and improves rendering speed. Add this code in header of your PHP page to see the effect. function sanitize_output($buffer){ $search = array( '/\>[^\S ]+/s', // strip whitespaces after tags, except space '/[^\S ]+\</s', // strip whitespaces before tags, except space '/(\s)+/s' // shorten multiple whitespace sequences ); $replace = array( '>', '<', '\\1' ); $buffer = preg_replace($search, $replace, $buffer); $buffer = preg_replace('/<!--(.|\s)*?-->/', '', $buffer ); return $buffer;}ob_start("sanitize_output");?>  

How to optimize Magento website performance

Magento if the most widely used e-commerce framework. In this post I have mentioned few important points through which we can optimize overall Magento website’s performance. Most optimizations will work with any version of Magento .  Note that here I assume your customized Magento website is build by following all the recommended coding standards (For more information about Magento coding standards please visit ). So, following are important points/guidelines you are supposed to follow to improve Magento performance. Enable Cache through Magento Admin Panel. Use minified js/css and enable Merge CSS/JS through Magento Admin Panel Enable code compilation after complete development. If updates, code modifications, extension installations are needed, code compilation needs to be disabled first. If not, there will be errors. Set HTTP Header Field Connection : Keep-Alive through server configuration. Do not t