Articles

Magic Erasers are awesome

So if you haven’t already bought something like this... don’t! I’ve found a solution (one among many, just google ‘clean macbook’ and you’ll get a slew of hits), and it is the Mr. Clean Magic Eraser. Not only do they take crayon and spaghetti sauce off of painted walls without damage (at least walls with a matte finish), but they also get that icky brown junk off of your laptop. Here is a high contrast photo of the before shot:

Continue Reading…

Posted by Steve on Sep 21, 2008

Mail Fetcher - Fetch Email from Ruby and Rails

I recently had to write something to fetch emails from a GMail account and process the emails to check if the email was a bounce (bad email address). If so, the person in the system associated with the bounced email would be deleted from the database. I did some searching for such thing and found this:

How to receive emails with Rails

About half way down the page you see an example for polling emails from a POP3 server (edited for space):
require 'net/pop'
require File.dirname(__FILE__) + '/../config/environment'

logger = RAILS_DEFAULT_LOGGER

logger.info "Running Mail Importer..." 
Net::POP3.start("mail.server.net", nil, "username", "password") do |pop|
  if pop.mails.empty?
    logger.info "NO MAIL" 
  else
    pop.mails.each do |email|

      begin
        logger.info "receiving mail..." 
        Mailman.receive(TMail::Mail.parse(email.pop))
        email.delete
      rescue Exception => e
        logger.error e.message
      end

    end
  end
end
logger.info "Finished Mail Importer."
Continue Reading…

Posted by Steve on Feb 17, 2008

Talking to Gmail with Ruby and Rails

Recently I came across a dilemma in trying to send and receive emails from a Rails app: Either install a full-blown postfix server on a Linux box (by full-blown, I mean account handling, POP/IMAP interface, anti-spam, anti-virus, etc etc), or use Google to handle all the emailing. So, me not being a Linux/sys-admin junkie, I strongly opted for the Google route (and after some persuasion the customer, thankfully, agreed :-). So I went about to find the best practices for working with Google Apps (http://www.google.com/a which is where you sign up). I came across this very helpful post.

You just install the mentioned plugin, create the appropriate mailer.yml file and you’re good to go. ActionMailer will login as the specified account and send emails through that account. Genius!

On a side note, I was able to get a Rails app to talk (no sending though, just receiving) to gmail by using the new net/pop library in the latest ruby and making the Mail Fetcher plugin.

But back to the main point, being able to send through the Google Apps account. The technical stuff seems really easy now. Just send your emails out like normal and have some way to check responses either manually or programmatically like I showed above. You’re golden, or so it seems.

Continue Reading…

Posted by Steve on Feb 11, 2008

bash aliases

Bash aliases are such lovely things, so I thought I would share some of my favorites and maybe even get some feedback.

Most of my aliases are there to make software development more enjoyable and less time consuming. As such, most of them deal with the projects I have in my project directories. Here are some of the more interesting ones:

for bigdir in $(ls ~/Developer/Projects/ | cut -d' ' -f7)
do 
  for dir in $(ls ~/Developer/Projects/$bigdir)
    do
      alias cd$dir="cd ~/Developer/Projects/$bigdir/$dir" 
      alias m$dir="cd$dir && mate ." 
      alias s$dir="cd$dir && ss" 
      alias g$dir="~/bin/svngrowl $dir" 
      alias o$dir="osascript -e 'tell application \"Terminal\"'
        -e 'tell application \"System Events\"'
        -e 'tell process \"Terminal\" to keystroke \"t\" using command down'
        -e 'tell process \"Terminal\" to keystroke \"t\" using command down'
        -e 'end tell'
        -e 'do script \"s$dir\" in first tab of front window'
        -e 'do script \"m$dir\" in second tab of front window'
        -e 'do script \"g$dir\" in third tab of front window'
        -e 'do script \"localhost\" in second tab of front window'
        -e 'tell second tab of front window to set selected to true'
        -e 'end tell'" 
    done
done

alias localhost="open http://localhost:3000" 
alias addall="svn st | grep ? | cut -d' ' -f7 | xargs svn add" 
alias removeall="svn st | grep ? | cut -d' ' -f7 | xargs rm -Rf" 

for var in "server" "generate" "console" "destroy" "plugin" 
do
  alias s${var:0:1}="script/$var" 
done
Continue Reading…

Posted by Steve on Nov 03, 2007

Rails and SSL (https://)

So I recently had to have some secure routes for a site I am currently working on. If you are using deprec and deploying to a slicehost, getting the SSL certificate stuff working is a snap. If you want your whole site to be over SSL, then all you do is put in a permanent redirect to socket 443 in your app_name.conf file. But, if you need to do something interesting like go back and forth between http and https, then you need to do a little digging.

Doing a google search doesn’t bring up anything particularly useful in terms of going back and forth between http and https, but one thing did catch my eye. In your routes you can pass a protocol option to set which protocol you are going to use (something like http, file, svn, https, etc…). I also had to dig through some code to find out how to pass that option in, since it gets set two different ways depending on what kind of route you are using. If you do a map.resource(s) route, then you have to set the option as :requirements => {:protocol => ROUTESPROTOCOL}, whereas if you just do a map.routename type route, then you just pass in :protocol => ROUTES_PROTOCOL.

Continue Reading…

Posted by Steve on Aug 28, 2007