Tutorial

How to run Python scripts in your shared hosting server

Direct to the how-to 🙂

  1. First make sure your hosting supports Python. Now a days almost all shared hosting providers support Python.
  2. Find your python installation location, this is required for “shebang” line added at the top of your python script. Usually this is /usr/bin/python or /usr/local/bin/python
  3. Make sure to include two print statements which will print the content-type and an empty line.
  4. Now put the script in cgi-bin directory inside your root public folder, usually public_html
  5. Change the permission of the script to 0755
  6. Try to browse now 🙂

How to generate getter/setter in PHP easily

For one of my current project I need to write getter/setter functions for 20+ variables. You know, how annoying it is! Well, I can use magic quotes, but I don’t like it. More over getter setter will help you later to use the class when your IDE (in my case Netbeans) supports auto complete suggestion. Though all Java development environments allow to generate getter and setter code automatically.
Then I started coding a php script for generating getter/setter for supplied variables, but I was lucky as suddenly I thought “why don’t I look for something like this online” 🙂

And here is the link I got, its quite good. http://www.icurtain.co.uk/getset.php, It saved my time.

How to enable Apache HTTP Authentication using PHP

The easiest way to password-protect a site is to use HTTP Authentication, where if a browser’s request for a protected page is not accompanied by the correct username and password, the Web server replies with an HTTP 401 error – which means “Unauthorized Access” – and an invitation for the browser to re-submit the request with a proper username and password. From the user’s point of view, most of this dialogue is hidden. Following that first failed request, the browser prompts the user (in a dialog box) for a username and password, and then re-submits the request, this time with the authentication information attached. Assuming the username/password combo is on the list of allowed users, the Web server then sends the page requested. The Web browser will likewise continue to send that username/password with all subsequent requests.

Look at the following code: