Posts

Showing posts with the label Ruby

Sending Email Using Gmail and Action Mailer

I've used this for a new site , which I'll be mentioning very soon. It took me quite some time to figure out and get right. The first thing to do is download the smtp_tls.rb file. I saved it in my Sinatra app, under lib . Next create a file called mailer.rb in the same lib directory with the following contents: require 'lib/smtp_tls' require 'action_mailer' class Mailer def my_email(from_email, from_name, message) recipients "marktucks@gmail.com" from from_email subject "Contact from " + from_name body :name => from_name, :email => from_email, :message => message end end Mailer.template_root = File.dirname(__FILE__) Mailer.delivery_method = :smtp Mailer.smtp_settings = { :address => "smtp.gmail.com", :port => "587", :domain => "YOUR_DOMAIN", :authentication => :plain, :enable_starttls_auto => true, :user_name => "YOUR_USERNAME...

Unit Testing Using Context

Jeremy McAnally has released a gem called context allowing contexts in Test::Unit tests. It's all the rage, even those crazy Rails guys are doing it (although I did check out some of their unit tests earlier and couldn't find any). Anyway, I'm way behind on my TDD and BDD and all other testing acronyms so I decided to give it a go. These are way simple tests and I actually did it the normal Rails way initially before "converting" to the context way of doing it. I've got converting up there in quotes because it was really, really simple and I hardly did anything which is fantastic because the easier something that's good is to do, the more people will eventually do it; think Rails conventions. Getting Started Get the gem: $ gem sources -a http://gems.github.com $ sudo gem install jeremymcanally-context That is outlined as the install procedure, but you can't just use it as you must require that bad boy for your Rails app to use it - so put this in...

Ubiquity: Firefox Command Line Awesomeness

Ubiquity - "a Mozilla Labs experiment into connecting the Web with language in an attempt to find new user interfaces that could make it possible for everyone to do common Web tasks quicker and easier." Getting started Install the Plugin , which will restart Firefox / Mozilla. *Note: if you are using a Mac you'll need to install Growl to get the notifications to work. Windows works out of the box, popping up those little toaster notifications in the bottom right of your screen. No messages on Linux just yet, but I'm sure there is someone out there clever enough to get this working or know how to get it working. Once restarted, hit CTRL+SPACE for Windows or OPTION+SPACE for Mac and you'll see Ubiquity pop up below your open tabs. There are already quite a few commands built in (type "command-list" into Ubiquity to see them all), follow this tutorial to get up and running. One of the sweet things about it is creating your own commands using the command...