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.

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

Wednesday, December 9, 2009

imeem acquired by myspace - bummer

nothing else to say really, imeem was a great service

I've never liked myspace


Thursday, November 12, 2009

Heroku - HTTP 502 Error

This might be helpful to someone?

I was receiving 'App Failed To Respond (HTTP 502) Bad Gateway' errors when deploying my application on Heroku. Reading the error codes page did not help me solve the problem, it took awhile but I was finally able to track it down.

The error was being generated in the browser but checking the rails logs, the requests were returning HTTP 200 success codes, so the problem was being generated at the web server level on the Heroku stack.

Turns out the problem was caused by setting response.header for no browser caching. I was using code similar to this post. Everything worked fine after I removed this line

  • response.headers["Expires"] = 0

Heroku - sending email with Gmail

I have been working on deploying a Rails application to Heroku. A couple of gotchas I ran into when following this post "Sending email with Gmail"

  • Don't use a dollar sign ($) in your password 
  • this can work locally if you put single quotes around the value, but on the heroku server it saved the entire string but at runtime would truncate it at the dollar sign
  • for example using the password 'left-side$right-side'
  • heroku config:add GMAIL_SMTP_PASSWORD=left-side$right-side
  • heroku config returns > GMAIL_SMTP_PASSWORD=left-side$right-side
  • heroku console 
  • type ENV['GMAIL_SMTP_PASSWORD'] returns > left-side

Heroku is running Ruby 1.8.6, locally I am running Ruby 1.8.7, I made a small hack to the plugin to avoid errors in development mode

./vendor/plugins/gmail_smtp/init.rb
changed the first line to
require 'smtp_tls' if RUBY_VERSION < "1.8.7" 

tls is already handled in 1.8.7 and this code must have been creating some type of conflict