Wednesday, May 28, 2008

IIS 5.1 Server Application Unavailable Error

I get this error sometimes when I change the default application in IIS.
When trying to browse my default.aspx page I get the big red font error "Server Application Unavailable".

I fix this issue by executing the following commands:
1) Give modify access to the "IIS_WPG"and "Internet Guest Account" users to your web directory. Try see if that works, if not continue with step2.


2) aspnet_regiis -i
3) iisreset

Microsoft Instructions:
To fix IIS mappings for ASP.NET, run the aspnet_regiis.exe utility:
1. Click Start, and then click Run.
2. In the Open text box, type cmd, and then press ENTER.
3. At the command prompt, type the following, and then press ENTER:
"%windir%\Microsoft.NET\Framework\version\aspnet_regiis.exe" -i
In this path, version represents the version number of the .NET Framework that you installed on your server. You must replace this placeholder with the actual version number when you type the command.


1. Click Start, and then click Run.
2. In the Open text box, type iisreset.

Done! Go check out your site it should be up and running.

Ruby: Display datetime - time in words - timeago helper function.

I found this function on the web and putted right into my helper class to display DateTime or Time into words. Displaying time in words is now more used on the web. Popular pages such as YouTube and Yahoo videos use this approach.

Copy the code and plugged into your helper class.

def timeago(time, options = {})
start_date = options.delete(:start_date) ||
date_format = options.delete(:date_format) || :default
delta_minutes = (start_date.to_i - time.to_i).floor / 60
if delta_minutes.abs <= (8724*60)
distance = distance_of_time_in_words(delta_minutes)
if delta_minutes < 0
return "#{distance} from now"
return "#{distance} ago"
return "on #{}"
def distance_of_time_in_words(minutes)
when minutes < 1
"less than a minute"
when minutes < 50
pluralize(minutes, "minute")
when minutes < 90
"about one hour"
when minutes < 1080
"#{(minutes / 60).round} hours"
when minutes < 1440
"one day"
when minutes < 2880
"about one day"
"#{(minutes / 1440).round} days"

Tuesday, May 27, 2008

Ruby: Format seconds into minutes to_minutes function

I created this function to turn seconds into minutes.
Example: 500 seconds should be displayed as 8:00 minutes.

def to_minutes(seconds)

m = (seconds/60).floor
s = (seconds - (m * 60)).round

# add leading zero to one-digit minute
if m < 10
m = "0#{m}"
# add leading zero to one-digit second
if s < 10
s = "0#{s}"
# return formatted time
return "#{m}:#{s}"