Posts

How to install python virtualenv in windows

Version used is python 2.7.  - Locate the executable pip.exe in your python installation folder (by default in root folder of your operating system drive)  -  Add the location e.g.  C:\Python27\Scripts  in variable path in your environment variables (System variables). You can now run globally the executables within that folder. The virtualenv exe will also be added in scripts directory. In the command line, run pip install virtualenv After installation you can try () virtualenv --version 

Basic Authentication Using .htaccess In Wamp/Xampp Server

This is how we create a basic authentication using .htaccess file in windows. The use case is when you provide a simple api to your client. This will secure the url with user and password using basic auth. Accessing the path and any files  below url user must authenticate first. http://localhost/secure/ Following the steps below we will have the .htaccess and .htpasswd inside \secure folder. This folder is in your local web server 1. Create the .htaccess file in folder that you want to secure (in this example secure/ folder). The .htaccess file should contain the 4 lines below    AuthType Basic  AuthName "Restricted Content"  AuthUserFile D:/wamp/www/secure/.htpasswd  Require valid-user 2. To create the .htpasswd file, using command line locate the bin directory ( where htpasswd.exe is located ) in the active version of apache ( D:\wamp\bin\apache\apache2.0.63\bin ). Run  htpasswd -c D:\wamp\www\secure\.htpasswd user should look like ...

Prevent parent anchor tag to redirect when a child is clicked

Listen to click event of a child element within anchor tag. <a href="www.google.com" id="parent">    <img src="image.jpeg"/>     <div id="child">Delete</div> </a> jquery approach $('a#parent').on('click', '#child', function(e){     e.preventDefault();          //you only need this if you have a click event in parent element     //e.stopPropagation();      alert($(this).html()); });

Use php exec(), php_exec() wamp server windows 8

Steps: Turn off safe mode in php.ini (Make sure you are editing the correct php.ini that corresponds to the right version of active php e.g. D:\wamp\bin\php\php5.3.5\php.ini) safe_mode = Off safe_mode_exec_dir = Off Usage: If you have myexecutable.exe in the same folder with test.php in your local server . Accessing http://localhost/test.php. You should see the output message of your executabe.   test.php <?php exec("myexecutable.exe", $output); var_dump($output);   //Page will not wait for the executable to finish. Uncomment pclose()if you //don't want the page to load waiting for the exe to finish //http://www.php.net/manual/en/function.exec.php //pclose(popen("start /B myexecutable.exe ", "r"));   ?> The page will wait for the executable to finished.

Issue with incorrect filename downloading or saving pdf file using acrobat plugins

When we try to secure our pdf files from direct url access using .htacess, we then encounter the problem in incorrect file name of downloaded pdf file. This is just a small issue but to the client this is a big hassle renaming each downloaded pdf to the correct filename. Solution   Just by including the url filename in the url like below will do the trick www.wtfthiscode.com/secure.php /mypdfilename ?key=hashkeytomypdffile Simple example on how to secure your public pdf file Since we can't directly transfer the files away from public folder and due to time constraints. We decided to settle with .htaccess   .htaccess RewriteEngine on RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wtfthiscode.com [NC] RewriteRule \.(pdf)$ - [NC,F,L] The rewrite rule prevents any direct access to pdf files where the .htaccess file is located. We put the .htaccess file in uploads directory. If you don't have problem with rewrite in your web server, accessing the url like...