The blog has moved to http://jessehouse.com/ ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Wednesday, February 17, 2010

rails send_data fails on IE when SSL enabled

Came across a nasty issue using rails send_data with IE. Everything worked fine until the pages were running under SSL / HTTPS. Turns out the issue is with file download over SSL when the Cache-Control and Pragma html headers are set to no-cache.

The error message from IE
Internet Explorer was unable to open this site. The requested site is either unavailable or cannot be found. Please try again later.
The fix...
# before calling send_data
response.headers.delete("Pragma")
response.headers.delete('Cache-Control')
This issue is not restricted to rails, any server side code that sets no-cache is subject to the same issue. Glad I was able to find this post.

see also kb-316431

Tuesday, February 16, 2010

Google Webmaster Tools Sitemap.xml issues

After uploading my sitemap.xml file to Google Webmaster Tools I received the following error message and no additional error details were included:

Error: The last attempt at downloading the Sitemap failed. The details below are representative of the last successful download.

I searched around a bit and found a forum post where someone said they get this error 'sometimes', but after switching to use a gzip formatted sitemap.xml file the error went away

on ubuntu

gzip ./sitemap.xml

compresses the file to ./sitemap.xml.gz and deletes the sitemap.xml file by default

after uploading Google was able to process without issue

Tuesday, January 26, 2010

install older version of rails and without the docs

I always forget these

sudo gem install --no-rdoc --no-ri --version 2.3.4 rails

Monday, January 18, 2010

Neat site to generate graphics

I needed to generate a sign up button - this site is so much easier than opening photoshop


Thanks cooltext!

Wednesday, January 6, 2010

Ruby Http Get with Net::HTTP


Resources



require 'net/http'
require 'uri'

def get_html_content(requested_url)
url = URI.parse(requested_url)
full_path = (url.query.blank?) ? url.path : "#{url.path}?#{url.query}"
the_request = Net::HTTP::Get.new(full_path)

the_response = Net::HTTP.start(url.host, url.port) { |http|
http.request(the_request)
}

raise "Response was not 200, response was #{the_response.code}" if the_response.code != "200"
return the_response.body
end

# this will fail with ArgumentError: HTTP request path is empty
s = get_html_content("http://www.google.com")
# these should be fine
s = get_html_content("http://www.google.com/")
s = get_html_content("http://github.com/search?q=http")
# above code does not handle redirects but raises exception for non-200
s = get_html_content("http://www.yahoo.com/") # http 302

Ruby Regex to remove script tags


Resources