Monday, May 31, 2010

How to get file extension in ruby and jquery

To get the file extension excluding the "." then do the following
@file_extension = file_name.split('.').pop()

To get the file extension along with "." then do the following
@file_extension = file_name.scan(/\.\w+$/)

Using Jquery
var ext = $('#file_field_id').val().split('.').pop().toLowerCase();

Thursday, May 27, 2010

Access to /etc/hosts denied while modifying host file

This problem occurs when you  do not have the administrative rights.
You get an error when you try to edit the LMHOSTS or HOSTS file under Windows Vista.
Access to C:\WindowsSystem32\drivers\etc\ hosts was denied
or
Cannot create the C:\Windows\System32\drivers\etc\hosts file.
Make sure that the path and file name are correct.

To solve this problem:
1. Click Start–>All Programs–>Accessories–>Notepad–>Run as administrator.
If you are prompted for an administrator password or for a confirmation, type the password, or click Allow.
2. Open the Hosts file or the Lmhosts file, make the necessary changes, and then click Save on the Edit menu.

Friday, May 21, 2010

How to make dynamic on focus popup in the grid.

If you have a data table and need to display a on focus popup which shows the related columns content then you can do the following:
<% @objects.each do |object| %>
           
                   <%=h object.name%>                 
                  Show
                   
                       
           
<% end %>
<% end %>