Googlebot meta tag!

There a re some pages I have, that will be deleted after one months. For SEO, I have to make sure, google doesn’t end up showing those pages in google result and end up with 404 on my page. There is a very easy way of resolving this issue. I just have to make sure I add a meta tag to those pages.

<META NAME=”GOOGLEBOT” CONTENT=”unavailable_after: 11-Mar-2011 10:00:00 EST”>

The date time should be in the RFC 850 format.

For more details see: http://googleblog.blogspot.com/2007/07/robots-exclusion-protocol-now-with-even.html

mini magick, magick it is :)

Today I learned to do two things in ruby/rails:

– Downloading images from and external link to my hard drive
– Resizing those images

Image Download:

To download the images, I used net/http as follows:

require ‘net/http’
require ‘uri’

url = URI.parse(‘http://www.example.com/oldone.jpg&#8217;)
req = Net::HTTP::Proxy(proxy_addr, proxy_port).get_response(url)
open(“newone.jpg”, “wb”) do |file|
file.write(req.body)
end

Please note: I needed the proxy addr and port, if thats not required, the “Proxy(proxy_addr, proxy_port)” can be omitted.

Image Resize:

To resize the images, I needed to install ImageMagick and mini_magick.

(In windows, mini_magick installation was easy, got it by “gem install mini_magick”, but for ImageMagick, I got the portable copy “ImageMagick-6.6.5-Q16-windows.zip” from http://www.imagemagick.org/script/binary-releases.php, and then copied all the .dll and .exe files to my ruby/bin directory, whew! it worked then!)

Here is the code for resizing image:

image = MiniMagick::Image.from_file(dir + (“oldone” + extension))
image.resize(“60X60”)
image.write(dir + (“newone” + extension))

What I learned!

Sorry to myself, I had a flow for writing and then it stopped 😦 I need to work on it. I have been passing some very depressive time, and trying to figure out why and how to recover it! Well, its not going to be easy. But I’ll try. In the meantime, am planning to write down small little things I learn everyday. I am not sure how frequently I can do that. But I’ve to try. I know that life is like that, we try, we fail! But that doesn’t mean we should stop!

What I learned yesterday:

-> If I have a hash table like, hash_test = {:’Cat’ => “Meow”, :’Dog’ => ‘Tom’}, to add a entry to this hash, I should the following: hash_test.merge! ({:’Pet’ => ‘Wow’})
-> Used Datepicker jQuery function for picking date, its a cool tool. Details: http://jqueryui.com/demos/datepicker/
->Used .to_i to convert a string to integer.
-> Using named scope in Animal model so that can be called along with all other condition in every place. So we define it like:
named_scope :is_pet, {:conditions=>”animal.is_pet==’true'”}
now, later I can use it like: Animal.find_pets_with_ears(@num_of_ears).is_pet

I liked this use of named scope, need to understand it more, this is very useful!