Tag: site


Human Time

I recently added the capability to display time in more human friendly terms. Basically, instead of saying Posted at 2007-11-30 20:18:36, a relevant post will say "posted 3 days ago". You can see this on every post or twitter on my site. I did not realize the full potential of Ruby until I sat down to write the code to make this happen. I simply extended Ruby's default Time class with the following:

class Time
   def humantime
            age = Time.now.to_i - self.to_i
            seconds_max = 60
            minutes_max = 3600
            hours_max   = 86400
            days_max    = 604800
            weeks_max   = 2629743
            months_max  = 31556926
            p = ''
            unit = ' second'
            if age < seconds_max
                amt = age
            elsif age < minutes_max
                amt = age/seconds_max
                unit = ' minute'
            elsif age < hours_max
                amt = age/minutes_max
                unit = ' hour'
            elsif age < days_max
                amt = age/hours_max
                unit = ' day'
            elsif age < weeks_max
                amt = age/days_max
                unit = ' week'
            elsif age < months_max
                amt = age/weeks_max
                unit = ' month'
            else
                amt = age/months_max
                unit = ' year'
            end

            if amt > 1
              p = 's'
            end

            humantime = amt.to_s + unit + p + " ago"
       end
end

So now, to get the time in human time, I just call the .humantime method that is now a part of every Time object.

added tags

Last night I added the tagging capability to this site. I figured that tags seem like a better way to keep things organized, rather than categories.

new website

Welcome to my new website :)

It is still very much under construction, but the jist of it is here. This site has been built using Ruby on Rails as an experiment, and then it turned into a full site. Ruby is awesome.

Tag cloud

  1. 1 entries are tagged with 2007
  2. 2 entries are tagged with applevalley
  3. 1 entries are tagged with archlinux
  4. 1 entries are tagged with automation
  5. 1 entries are tagged with bigsur
  6. 5 entries are tagged with burningman
  7. 3 entries are tagged with code
  8. 1 entries are tagged with cplusplus
  9. 1 entries are tagged with desert
  10. 1 entries are tagged with drinks
  11. 1 entries are tagged with dspam
  12. 2 entries are tagged with dunes
  13. 1 entries are tagged with energy
  14. 1 entries are tagged with esplanade
  15. 5 entries are tagged with europe
  16. 1 entries are tagged with evdo
  17. 1 entries are tagged with flv
  18. 1 entries are tagged with gadgets
  19. 1 entries are tagged with government
  20. 2 entries are tagged with losangeles
  21. 1 entries are tagged with motivation
  22. 1 entries are tagged with moving
  23. 1 entries are tagged with newserver
  24. 1 entries are tagged with rails
  25. 2 entries are tagged with recipe
  26. 5 entries are tagged with ruby
  27. 1 entries are tagged with salmon
  28. 3 entries are tagged with site
  29. 1 entries are tagged with snow
  30. 6 entries are tagged with travel
  31. 1 entries are tagged with trip
  32. 1 entries are tagged with website
  33. 2 entries are tagged with work
  34. 1 entries are tagged with x4200
  35. 3 entries are tagged with yz250

Twitter Updates

Links to check out

Subscribe RSS