Force download in apache


Written on February 27, 2008 – 12:31 am | by Rene

if you want to force certain kind of files to pop up the save as dialog box, you have to add the AddType directive with the value application/octet-stream to the .htaccess file like this:

  1.  
  2. AddType application/octet-stream .csv
  3. AddType application/octet-stream .xls
  4. AddType application/octet-stream .doc
  5. AddType application/octet-stream .avi
  6. AddType application/octet-stream .mpg
  7. AddType application/octet-stream .mov
  8. AddType application/octet-stream .pdf
  9.  

and that’s all, now everything works fine

Configure ubuntu to use mod_rewrite


Written on February 12, 2008 – 11:58 pm | by Rene

To enable mod_rewrite on Ubuntu is pretty easy what we have to do is, first we enable the apache module for mod rewrite with this line.

  1.  
  2. sudo a2enmod rewrite
  3.  

After that we have to edit the file /etc/apache2/sites-avalible/default, then we look for this:

  1.  
  2. <Directory /var/www/>
  3.     Options Indexes FollowSymLinks MultiViews
  4.     AllowOverride None
  5.     Order allow,deny
  6.     allow from all
  7.     # This directive allows us to have apache2’s default start page
  8.     # in /apache2-default/, but still have / go to the right place
  9.     #RedirectMatch ^/$ /apache2-default/
  10. </Directory>
  11.  

And then we replace “AllowOverride None” by “AllowOverride All”, this line tells apache to read the .htaccess file, that is the file where we will put our rewrite rules.

  1.  
  2. <Directory /var/www/>
  3.     Options Indexes FollowSymLinks MultiViews
  4.     AllowOverride All
  5.     Order allow,deny
  6.     allow from all
  7.     # This directive allows us to have apache2’s default start page
  8.     # in /apache2-default/, but still have / go to the right place
  9.     #RedirectMatch ^/$ /apache2-default/
  10. </Directory>
  11.  

finally we just reload apache

  1.  
  2. sudo /etc/init.d/apache2 restart
  3.  

now we have pretty urls for our sites. :)

Send a post request to a popup


Written on January 26, 2008 – 1:11 am | by Rene

Today i want to send the post request from a form to a pop up window and the solution is pretty simple first we have to create our form and then we add a target attribute where we specify the name that our popup window will have second we add a onsumbit call to the form that will popup the new window and submit the form we also have to assign and id to our form that will be usefull when calling the function that popup the windows

  1.  
  2. <form action="index.php" method="post" target="windowName" onsubmit="return postPopup();" id="postForm">
  3.  <input type="text" name="value1" />
  4.  <input type="text" name="value2" />
  5.  <!– put all the form elements here –>
  6.  <input type="submit" />
  7. </form>
  8.  

  1.  
  2. <script type="text/javascript">
  3. function postPopup( formElem ) {
  4.         // here we popup the new window, the second attribute have to be the same as the form target attribute
  5.         window.open( , ‘windowName’, ‘width=800, height=400, resizable=yes, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no’ );
  6.         // we submit the form 50 milliseconds after so the browser creates the popup
  7.         setTimeout("document.getElementById(’postForm’).submit();",50);
  8.         // we stop the regurar form submit
  9.         return false;
  10. }
  11. </script>
  12.  

Real housewives write extensions.


Written on December 12, 2007 – 1:48 am | by Rene

One of the firefox extensions that i have installed is View Source Chart wich as said on the extension page “Draws A Color-Coded Chart of a Web Page’s Source Cod” what i like about it, is that it displays the html generated by javascript and the original code, not only the code viewable with the “view source” option.

i was using it when i realized that at the very bottom there is a hided message “Real housewives write extensions”, i attached an image of that message

viewsourcechart

What is this?


Written on September 18, 2006 – 11:20 pm | by Rene

What is this all about?

Well i am a Mexican computer science engineer, focused on web development, i like to work with perl, php, css, xhtml, javascript, ajax, etc. and this will be my playground. Where i will put my experiences while i am working, learning and living from web development.

My first languaje is not english, so if something is not well written please let me know