Ajax Request Monitoring in Chrome

In Firefox, you could use Firebug which allows  to view every http request that ajax calls are making. How to view each ajax request in Chrome developer tools?

How to view Ajax HTTP requests in Chrome

  1. Use CTRL+SHIFT+I (or navigate to Current Page Control > Developer > Developer Tools. In the newer versions of Chrome, click the Wrench icon > Tools > Developer Tools.) to enable the Developer Tools.
  2. From within the developer tools click on the Network button. If it isn’t already, enable it for the session or always.
  3. Click the "XHR" sub-button.
  4. Initiate an AJAX call.
  5. You will see items begin to show up in the left column under "Resources".
  6. Click the resource and there are 2 tabs showing the headers and return content.

How to view HTTP headers in Google Chrome

Chrome has a tab “Network” in Developer Tools with several items and when you  click on them you can see the headers on the right in a tab after choosing an item.

To show Chrome Developer Tools press F12 or CTRL+SHIFT+I on Windows or ⌥⌘I on a Mac.

enter image description here

Python in 10 minutes

If you want to learn the Python programming language but can’t find a concise and yet full-featured tutorial – this tutorial will attempt to teach you Python in 10 minutes. It’s probably not so much a tutorial as it is a cross between a tutorial and a cheatsheet, so it will just show you some basic concepts to start you off. Obviously, if you want to really learn a language you need to program in it for a while. I will assume that you are already familiar with programming and will, therefore, skip most of the non-language-specific stuff. The important keywords will be highlighted so you can easily spot them. Also,pay attention because, due to the terseness of this tutorial, some things will be introduced directly in code and only briefly commented on. Continue reading Python in 10 minutes

How to get client IP address in PHP

Are you using $_SERVER[‘REMOTE_ADDR’] to find the the client’s IP address in PHP? Well dude, you might be amazed to know that it may not return the true IP address of the client at all time. If your client is connected to the Internet through Proxy Server then $_SERVER[‘REMOTE_ADDR’] in PHP just returns the the IP address of the proxy server not of the client’s machine. So here is a simple function in PHP to find the real IP address of the client’s machine. There are extra Server variable which might be available to determine the exact IP address of the client’s machine in PHP, they are HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR. Continue reading How to get client IP address in PHP

Check POST values in PHP

In some case you have to check what method was used to request your web page or check some values in POST parameters.

You have two options to check it using PHP.

1. Check if there’s ANY POST data at all

//Note: This resolves as true even if all $_POST values are empty strings
if (!empty($_POST))
    // handle post data
    $fromPerson = '+from%3A'.$_POST['fromPerson'];
    echo $fromPerson;

2. Only check if a PARTICULAR Key is available in post data

Try these PHP code to check some POST parameter:

if (isset($_POST['fromPerson']) )
    $fromPerson = '+from%3A'.$_POST['fromPerson'];
    echo $fromPerson;

Python 3

What are the differences?

Short version: Python 2.x is legacy, Python 3.x is the present and future of the language

Python 3.0 was released in 2008. The final 2.x version 2.7 release came out in mid-2010, with a statement of extended support for this end-of-life release. The 2.x branch will see no new major releases after that. 3.x is under active development and has already seen over five years of stable releases, including version 3.3 in 2012, 3.4 in 2014, and 3.5 in 2015. This means that all recent standard library improvements, for example, are only available by default in Python 3.x. Continue reading Python 3

Install, configure and protect Awstats for multiple nginx vhost on Debian/Ubuntu

There’s already a lot of tutorial on internet on how to install awstats for nginx. I didn’t find any for the configuration I wanted, so I’ll write one, for my record.

I have some custom needs, let’s suppose I have 3 domains :

  • master-domain.com
  • alpha.com
  • beta.com

And I want to have stats for the 2 latest domains. The master-domain.com is used as the master domain of the server, with awstats available at awstats.master-domain.com, instead of having alpha.com/awstats and beta.com/awstats. The idea it to group all the server script/tools (phpmyadmin, zabbix, etc …) under master-domain.com. Continue reading Install, configure and protect Awstats for multiple nginx vhost on Debian/Ubuntu