Jason

Textmate Next and Previous Tab Keys

If you’ve just upgraded to Revision 1616 of Textmate, you may be wondering why your next and previous file tab keys stopped working. The author of Textmate recently changed the next and previous file tab key shortcuts to the universal mac application equivalents. Here it is in the release notes:

[CHANGED] Change next/previous file tab key equivalents to shift command [ and ]. This has become the de facto standard.

I tried to deal with this for a few days but that keyboard shortcut is just too ingrained in my brain. You can fix this, though, by going in to your Keyboard preference pane, then the "Keyboard Shortcuts" tab. Under "Application Shortcuts" click the plus button, find TextMate, and add the following:

TextMate Keyboard Shortcuts

Voila. Fixed! Now you can get back to coding at the speed of thought.

The Changelog Joins The Genius Pool

changelog

I just posted this over on my redesigned company site but it’s awesome so I had to share it here too. The Changelog, an amazing development podcast, is now part of the Genius Pool Network. Check out the blog post on Twisted Mind, over on The Changelog, or post a job now.

Rails 3.0 rc2 Notes

With the recent release of Rails 3.0 Release Candidate 2, DHH posted on the official Rails blog to check out the sweet GitHub compare view between the two RCs for detailed information. This list is by no means complete but I made some notes from the commit view, with links where possible, about the bigger changes:

Genius Pool Supports Twitter Integration

Genius Pool on Twitter

This has been around for a little while now, but Genius Pool now has Twitter integration when a new job is posted. Check it out and post a job.

Mac OS X Post Install Guide, May 2010

Part 1: Update Software

This takes a while. Go get some coffee and install the developer tools.

System Settings

Appearance

Scroll Arrows at top and bottom

Place scroll arrows at top and bottom. This is a left over windows preference I just can’t get used to.

Finder

Finder Buttons

Add delete and get info to toolbar. I’m of the opinion that this should be the default.

Keyboard

Modifier Keys Full Keyboard Access

The Keyboard is a pretty big deal for developers. Here are my settings:

Get some Emacs keybindings in all of cocoa:
http://www.gnufoo.org/macosx/. I’m a vim guy but they’re useful.

Modifier keys, set caps lock to control. Allow Full keyboard access also.

keyboard settings
Uncheck "Illuminate keyboard in low light conditions" for better battery life.

Apps

  • BetterTouchTool

    Adds a bunch of configuration options for the Magic Mouse. I set a 3 finger tap for spaces. It’s handy.

  • Dropbox

    Effortlessly sync files across computers. If you use the link above I get some free space. Use this one for a referral free link if you prefer.

  • Skitch

    Capture screenshots, share images. This has become so ingrained in my day to day use I don’t know what I’d do without it.

  • Evernote

    Enhanced syncable notepad. I use this for everything from code snippets to projects notes, recipes, and everything in between.

  • Google Chrome Beta

    I couldn’t do without it. Spice it up with some developer extensions and you’re good to go.

  • Mailplane

    Gmail on the desktop. I’ve tried almost every os x mail solution and couldn’t get more productive than Gmail. However, I still keep Mail.app configured in case I need to refer to old mail offline.

  • Textmate

    This is practically a necessity. The best text editor on OS X.

  • MacVIM

    It’s no emacs but it’s good to have around.

  • iStat Menus

    istat menus Find out useful information about what’s going on in your system. I mainly use this for the calendar widget in the menu bar. Why this isn’t an option in OS X by default I’m not sure. It recently became a paid app and I upgraded immediately.

  • Concentrate

    Eliminate distractions. I’ve written about this one before in my Using concentrate for the Pomodoro Technique post.

  • Adium

    Multi protocol IM client. I use it when not forced to use iChat by others.

  • Skype

    Needed for work and for recording podcasts.

  • BusyCal

    Think of it as iCal pro. I like this better for syncing with Google Calendar.

  • Things

    The best to do list app on OS X.

  • LaunchBar 5

    LaunchBar is an app launcher and more. Although, to be fair, I’m giving Alfred a shot right now, too.

  • SuperDuper!

    I don’t even use Time Machine because of SuperDuper! It’s a great backup program, though the target is a bit different than Time Machine. It’s well worth the money because of the smart backup feature.

  • ChoosyChoosy

    Choosy is a “better default browser” for os x. It lets you choose which browser you want to open a link in. It’s really invaluable when you get used to it.

  • TrueCrypt

    Described on the web site as “Free open-source disk encryption software for Windows 7/Vista/XP, Mac OS X, and Linux.” I use it for an encrypted disk image where I hold my financial information. This image is kept in my Dropbox and synced when ever it’s unmounted automatically.

  • Tweetie

    My favorite OS X Twitter client so far.

  • RSS Menu

    RSS Menu lets you track rss feeds in your menu bar. I don’t have all my feeds in here but a few select ones, like twitter searches that I want to pay attention to.

  • Developer Stuff

    • Git branch in Bash Prompt. This goes in ~/.bash_profile:
      parse_git_branch() {
        git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ →\ \1/'
      }
       
      export PS1='\[\e[1;37m\][\[\e[1;35m\]\u\[\e[1;37m\]@\[\e[1;32m\]\h\[\e[1;37m\]:\[\e[1;36m\]\w\[\e[1;33m\]$(parse_git_branch)\[\e[1;37m\]]$ \[\e[0m\]'
      This will make your prompt look like this:
      gitbranch.png
    • Git config (~/.gitconfig:
      [alias]
      	st = status
      	co = checkout
      	br = branch
      	ui = update-index
      	lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %f %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
    • Domain checking obsession. Put this in ~/.bash_profile, courtesy of Chris Wanstrath:
      function isreg {
      	whois $1 | grep -q 'No match' && echo "No" || echo "Yes"
      }
      Use as follows:
      $ isreg jasonseifer.com
      Yes
    • Put the following in ~/.inputrc. Create it if it doesn’t exist. Paste in the following:

      set show-all-if-ambiguous On
      set completion-ignore-case on
      "\ep": history-search-backward
      "\e[A": history-search-backward
      "\e[B": history-search-forward

      Now you can use tab to auto complete ignoring case and also suggest more options. The history search stuff lets you use the up arrow to search backwards through your history by typing in the first few letters of a command you’ve typed before and going back through. It’s like ctrl+r but easier.

    • Install Homebrew. Then:

        brew install wget
        brew install git
        brew install mysql
    • Ruby:

      First thing’s first. The version of rubygems that comes with Snow Leopard is a bit outdated. Update it:

      sudo gem update --system

      RVM is the Ruby Version Manager. It lets you have multiple versions of Ruby installed on you system. But it’s much more than that. You can also have gemsets which are preconfigured sets of gems. I’ve been using one gemset per project.

      Local rack apps can easily be hosted with Passenger Pane. Then you can also set up your rdocs for local viewing without using gem server. The instructions in the article still work, you just need to keep an old version or rdoc installed.

      mategem command to edit a gem in Textmate with completion:

      _mategem()
      {
          local curw
          COMPREPLY=()
          curw=${COMP_WORDS[COMP_CWORD]}
          local gems="$(gem environment gemdir)/gems"
          COMPREPLY=($(compgen -W '$(ls $gems)' -- $curw));
          return 0
      }
      complete -F _mategem -o dirnames mategem
    • PeepOpen is a new application from PeepCode that gives you a smarter fuzzy file search (like in TextMate) and also works in MacVim and Emacs. It really helps out in MacVim and is much easier to configure than the fuzzy file finder plugin.

    Wrapping Up

    This isn’t everything I use but It’s a pretty good start. If you have any must have apps or dev environment shortcuts, please post in the comments.

Friends Around Me

Friends Around Me

I’d like to congratulate Friends Around Me with their official launch today. I was involved with doing some back-end development for this project. It’s mainly an iPhone (and iPad!) app with a Rails back-end. It’s a great idea from a very talented group of people whom I was lucky to work with. Check out the site or grab the app from iTunes.

Rails Envy

Many have asked what happened to Rails Envy so I thought it was time to tell the story. Fair warning: this gets a bit personal at times.

A Brief Bit About Me

I went to school for Psychology where I got a Bachelor of Science at the University of Central Florida. I took some programming classes but was always a "closet geek." I’ve been programming since I was 6 years old and Ruby and Rails just felt right when I found it. Even more so after coming from PHP, Perl, C, and (shudder) some MS Access coding. Right around when I was finishing college I started attending ORUG meetings and some hackfests. This is where I met Gregg Pollack. We got along great, especially with coding.

Where Rails Envy Came From

I think I attended all but the first Orlando Ruby Users Group and occasionally gave presentations. On the Tuesday, November 14th meeting I gave a presentation on using RJS in Rails. I actually thought it was a good idea to use the term "AJAXified" in a presentation description, but I digress. That night I was joking around with someone and we decided a local [insert other language here] developer had "Rails Envy." At the time, I thought it would make a pretty funny Rails focused blog name so I registered the domain. Then I sat on it for a while.

At some point in all this, Gregg, who has his Patched Software consultancy at the time, asked me to come work for him on a contract basis because he needed help on a project. This actually terrified me at the time. What would I do when the contract ran out? How would I find other work? I was pretty fresh out of college and hadn’t considered going contract. After talking it over with a lot of people, I quit my job.

Full Time to Contract

Me and Gregg
This picture has nothing to do with the paragraph, but it’s from that time period.

Coming from the full time employment world, working on a contract basis was a wonderful experience. I was working while wearing a t-shirt and shorts! Plus, the work was fascinating to me. I remember working with Gregg to solve some very interesting Ruby and Rails problems of the time. There were always people blogging but not as many as today and a lot of the time you had to dive deep in to Rails rather than googling solutions. It’s inspiring to see how far Rails has come.

After I working with Gregg for a little while I convinced him that we needed a blog. Gregg wasn’t convinced we were qualified enough to write a blog. I remember saying that we didn’t have to be because we had something to offer people based on our experience developing Rails full time. This was a different time — not many people were doing full time Rails work. We used railsenvy.com, set up Mephisto, and we were rolling.

We weren’t expecting the amount of feedback we got. It was great.

We Make Some Videos

I remember leaving ORUG one night and saying to Gregg "Wouldn’t it be funny if we parodied the Mac vs PC ads only using Ruby on Rails and other web development frameworks?" I was just joking but Gregg convinced me it would be a good idea to actually shoot these. I remember writing some script on a notepad during ORUG about a guy running in a track suit. I’m really glad that one didn’t make it in. Anyway, Gregg set up a writeboard (password: railsenvy), we bounced some ideas back and forth, got in touch with a friend of mine who did video work, and actually shot the videos.

Shooting the videos turned out to take a lot longer than I expected. It also was much more fun than I expected. I think the original set of four took nearly two full days including rehearsals. I still love the bear in a jar for hibernate. The videos went viral and that was awesome. I think I have a screenshot somewhere of 3 of the videos being in various spots on the front page of digg at the same time.

Gregg managed to get in contact with Chad Fowler and have the videos played at the first Railsconf. That was a truly exciting experience. I wasn’t expecting it at all and was flattered that they even considered playing them. After Railsconf we made some more. To this day I’m still embarrassed by the myspace one.

Hey, Let’s Start a Podcast!

Rails Envy

I wasn’t much of a podcast listener. Gregg turned me on to the amazing Radio Lab and This American Life podcasts. I had noticed at the time that there weren’t any Ruby or Rails news podcasts. I remember it took some convincing of Gregg to get one started. My original pitch was something like "Just a five minute thing where we read what’s new. We’re reading all of the RSS feeds anyway" "Why would people listen to us when they could just read RSS feeds?" "Some people like listening to podcasts. And we’re funny." After doing some research on how to set up a successful podcast (Thanks Miles and Ryan!) we were up and running.

I learned a ton about editing podcasts. Dan taught me why I should use compression rather than normalization under certain circumstances. For the longest time, I used Soundtrack Pro to edit the podcasts. I think I did the first 40 episodes in Soundtrack before learning Pro Tools. Gregg and I would record each story separately and assemble them later. It usually took three takes if we messed up. Which was often. Looking back, I can’t believe I edited over 90 of them. Every week. It was a lot of work but I loved doing it.

Rails Can’t Scale

Can Rails Scale?

I think a lot of people were wondering why a Rails developer would be saying that Rails can’t scale, very often at least once a week. When I started this meme there were a lot of blog posts and questions about the time about Rails and scalability. People were citing Twitter as an example of Rails not being able to scale during their fail whale days. Java people were saying Ruby is slow. TechCrunch was all over it.

My idea was to make the expression "Rails can’t scale" so tired out that people would get sick of hearing it. When people commented asking me to stop, I knew I was doing a good job. Sorry everyone. But it was for a good cause. There’s a lot less sentiment these days about Rails not being able to scale. I’d like to think I played a small part in that.

Working for The Man!

Halogen Guides

Gregg and I were approached by Dan Benjamin about working for a startup called Helium Report (now Halogen Guides). We accepted. I got the opportunity to work with a kick ass team. I have nothing but praise and respect for everyone I worked with. We had our challenges but I think we handled them well. I wrote some pretty good code, if I do say so myself. However, for reasons I’m about to outline, I wasn’t able to keep the job.

Tragedy Strikes

This part is difficult for me to write. Gregg mentioned in his post that I moved to Ft. Lauderdale for a year but didn’t say why. On May 1st, 2008, my mother woke up to find my father missing from the house. She was very worried and under a lot of stress at the time. My sister and I eventually found my dad, though my mother suffered her second heart attack while we were looking for him. She passed away a few days later.

Words can’t convey how deeply I miss her. I think about her every day. She was an amazing human being and I’m proud to be her son. I owe her a lot and I’m largely the person I am today because of her.

I’m not sure people ever really "get over" these kinds of things; rather, you find a new normal. I got a lot of supportive emails when Gregg announced this at the end of the podcast. I’m sorry if you emailed and I never got back to you.

I wasn’t able to keep a job while all of this was going on. However, everyone at Halogen Guides was ridiculously, above and beyond, supportive. For that I’m extremely grateful. I wish everyone nothing but the best.

Some Good Comes out of it

My girlfriend Candace and I moved to South Florida to help take care of my father. She selflessly changed jobs and moved in with my father and I. This sealed the deal in my mind and I proposed. She said yes. She’s a wonderful person and we’re getting married September 25th, this year. I couldn’t be happier, even though I’m a bit difficult at times. I probably wouldn’t have been able to get through everything without her support and the support from some very good friends. You know who you are. I thank you all deeply.

Wrapping Up

With me living in South Florida and Gregg in Orlando, each working on different projects, it started to become more difficult to do the podcast which was still going strong. We did our best but it started making more sense to split off in to our own companies. I started Twistedmind Inc. where, among other things, I offer consulting services scaling Rails. Dan Benjamin took over the reigns as co-host of the podcast, which we eventually moved over to 5by5. We also started The Dev Show to do a big longer discussion on general programming topics.

Moving On

Though we have mutually decided to take the Rails Envy web site down, I feel that Rails Envy, and what Gregg and I accomplished together, should be celebrated. I’m proud of the work we did and what we accomplished as a team. I’m proud of the videos, podcasts, talks, and client work we did. I’m grateful for the opportunities to have met and worked with so many people. It was a great experience. I hope to continue to set the bar high doing client work through my new company, Twistedmind (Hire me!), being a part of podcasts like The Ruby Show and The Dev Show, and launching projects like Genius Pool and Employee Scheduling software. I wish everyone the best. See you soon.

Rake Tutorial

If you’re developing with Rails you’ve probably encountered rake once or twice. This blog post aims to walk you through where rake came from and an introduction on how to use it effectively in your Rails apps.

A Little Bit of History

Rake is the project of Jim Weirich. It’s a build tool. For a good laugh and an even more in depth history check out the "rational.rdoc" from the Rake documentation. Essentially, rake started as an idea for using Ruby inside of a Makefile. Though Jim doesn’t sound convinced from the tone in that document, it is a good idea.

What’s the need for an automated build system at all? As usual, Wikipedia has the answer:

Historically, developers used build automation to call compilers and linkers from inside a build script versus attempting to make the compiler calls from the command line. It is simple to use the command line to pass a single source module to a compiler and then to a linker to create the final deployable object. However, when attempting to compile and link many source code modules, in a particular order, using the command line process is not a reasonable solution. [sic]
As the build process grew more complex, developers began adding pre and post actions around the calls to the compilers such as a check-out from version control to the copying of deployable objects to a test location. The term “build automation” now includes managing the pre and post compile and link activities as well as the compile and link activities.

It’s about Dependencies

This may be a bit of a stretch to say but build tools are about dependencies. One file or set of files depends on another set to get compiled, linked, or other fun things before the next set can be processed. The same idea exists in rake with tasks and task dependencies. Let’s look at a simple rake task. Save the following as “Rakefile” in any directory:

  directory "tmp"
 
  file "hello.tmp" => "tmp" do
    sh "echo 'Hello' >> 'tmp/hello.tmp'"
  end

What we’re saying here is that the file named “hello.tmp” depends on the directory "tmp". When rake runs across this, it’s going to create the directory "tmp" first before running the "hello.tmp" task. When you run it, you’ll see something like the following:

  [jason@brick:~/src]$ rake hello.tmp
  (in /Users/jason/src)
  echo 'Hello' > 'tmp/hello.tmp'

If you were to look at the "hello.tmp" file you would see the phrase "Hello". What happens if you run it again? You’ll see the same output again. What’s going on? Rake is generating the file again. It’s doing this because it can’t actually find the file tmp/hello.tmp from that definition. Let’s redefine the task:

  directory "tmp"
 
  file "tmp/hello.tmp" => "tmp" do
    sh "echo 'Hello' > 'tmp/hello.tmp'"
  end

Now if you were to run it twice you would see something like this:

  [jason@brick:~/src]$ rake "tmp/hello.tmp"
  (in /Users/jason/src)
  mkdir -p tmp
  echo 'Hello' > 'tmp/hello.tmp'
  [jason@brick:~/src]$ rake "tmp/hello.tmp"
  (in /Users/jason/src)

Rake now knows that the file task has been run.

Running Other Tasks

Rake tasks can take the form of having prerequisites and can depend on another task. Let’s say I wanted to get ready in the morning. My process would be something like this:

  1. Turn off alarm clock.
  2. Groom myself.
  3. Make coffee.
  4. Walk dog.

Let’s further assume that I have OCD and have to do all of these in order. In rake I might express my morning as follows:

  task :turn_off_alarm do
    puts "Turned off alarm. Would have liked 5 more minutes, though."
  end
 
  task :groom_myself do
    puts "Brushed teeth."
    puts "Showered."
    puts "Shaved."
  end
 
  task :make_coffee do
    cups = ENV["COFFEE_CUPS"] || 2
    puts "Made #{cups} cups of coffee. Shakes are gone."
  end
 
  task :walk_dog do
    puts "Dog walked."
  end
 
  task :ready_for_the_day => [:turn_off_alarm, :groom_myself, :make_coffee, :walk_dog] do
    puts "Ready for the day!"
  end

If I were to run this as is I would type rake ready_for_the_day and I’d see the following:

  [jason@brick:~/src]$ rake ready_for_the_day
  (in /Users/jason/src)
  Turned off alarm. Would have liked 5 more minutes, though.
  Brushed teeth.
  Showered.
  Shaved.
  Made 5 cups of coffee. Shakes are gone.
  Dog walked.
  Ready for the day!

By running the ready_for_the_day task it notices that the turn_off_alarm, groom_myself, make_coffee, and walk_dog tasks are all prerequisites of the ready_for_the_day task. Then it runs them all in the appropriate order. You’ll notice that we can pass something in to the make_coffee task. If we were having a really tough day we could pass in a value to the COFFEE_CUPS environment variable and be more prepared:

  [jason@brick:~/src]$ rake COFFEE_CUPS=5 make_coffee
  (in /Users/jason/src)
  Made 5 cups of coffee. Shakes are gone.

Namespaces

Rake supports the concept of namespaces which essentially lets you group together similar tasks inside of one namespace. You’d then specify the namespace when you call a task inside it. It keeps things tidy while still being quite effective. In Rails, you might notice the db:migrate task. In that example, db is the namespace and migrate is the task. Using the above example, we might put everything in to the morning namespace:

  namespace :morning do
    task :turn_of_alarm
    ....
  end

Now if you were to run rake COFFEE_CUPS=3 morning:ready_for_the_day you would have the same output as above, only it only took 3 cups of coffee today. Score!

The Default Task

Rake has the concept of a default task. This is essentially the task that will be run if you type rake without any arguments. If we wanted our default task to be turning off the alarm from the example above, we’d do this:

  task :default => 'morning:turn_off_alarm'

Running rake now produces the following:

  [jason@brick:~/src]$ rake
  (in /Users/jason/src)
  Turned off alarm. Would have liked 5 more minutes, though.

Describing Your Tasks

You can use the desc method to describe your tasks. This is done on the line right above the task definition. It’s also what gives you that nice output when you run rake -T to get a list of tasks. Tasks are displayed in alphabetical order. We’ll define some descriptions in our Rakefile (abbreviated for brevity):

  ...
  desc "Make coffee"
  task :make_coffee do
    cups = ENV["COFFEE_CUPS"] || 2
    puts "Made #{cups} cups of coffee. Shakes are gone."
  end
  ...

Now when we run rake -T for our list of tasks we get the following output:

  [jason@brick:~/src]$ rake -T
  (in /Users/jason/src)
  rake afternoon:make_coffee      # Make afternoon coffee
  rake morning:groom_myself       # Take care of normal hygeine tasks.
  rake morning:make_coffee        # Make coffee
  rake morning:ready_for_the_day  # Get ready for the day
  rake morning:turn_off_alarm     # Turn off alarm.
  rake morning:walk_dog           # Walk the dog

You can add in a string to get tasks matching that displayed. Running rake -T af would show just the afternoon task.

Redefining Tasks

Let’s say you want to add on to an existing task. Perhaps you have another item in your grooming routine like styling your hair. You could write another task and slip it in as a dependency for groom_myself but you could also redefine groom_myself later on (shortened for brevity but you get the idea):

  namespace :morning do
	....
	task :groom_myself do
      puts "Brushed teeth."
      puts "Showered."
      puts "Shaved."
    end
    ....
  end
  ...
  namespace :morning do
    task :groom_myself do
      puts "Styled hair."
    end
  end
  [jason@brick:~/src]$ rake morning:groom_myself
  (in /Users/jason/src)
  Brushed teeth.
  Showered.
  Shaved.
  Styled hair.

Invoking Tasks

You may at some point want to invoke a task from inside another task. Let’s say, for example, you wanted to make coffee in the afternoon, too. If you need an extra upper after lunch you could do that the following way:

  namespace :afternoon do
    task :make_coffee do
      Rake::Task['morning:make_coffee'].invoke
      puts "Ready for the rest of the day!"
    end
  end

Which outputs:

  [jason@brick:~/src]$ rake afternoon:make_coffee COFFEE_CUPS=1
  (in /Users/jason/src)
  Made 1 cups of coffee. Shakes are gone.
  Ready for the rest of the day!

A real world example of this is the rcov:all task. I use this in Genius Pool for aggregate rcov data. It’s shamelessly stolen from Clayton Lengel-Zigich. Go check out that post for a good example of invoking other tasks from rake.

Refactoring

You’ll notice in the example above we’re delegating most of the work to already defined methods and tasks in the RSpec and Cucumber classes. As a general rule, try to keep your methods already defined other places and call them from rake with your specific options and use cases. Let’s say I had a Rails application that e-mailed all accounts in the system that their account was expiring in a certain number of days. Here’s one way to write it:

  namespace :accounts do
    desc "Email expiring accounts to let them know"
    task :email_expiring => :environment do
      date = ENV['from'] ? Date.parse(ENV['from']) : Date.today
      accounts = Account.find(:all, :conditions => ["expiration_date = ?", date]
      accounts.each do |account|
        Notifier.deliver_account_expiration(account)
      end
    end
  end

A better way, that would let you test it more thoroughly would be to do the following:

  namespace :accounts do
    desc "Email expiring accounts to let them know"
    task :email_expiring => :environment do
      date = ENV['from'] ? Date.parse(ENV['from']) : Date.today
      Account.notify_expiring(date)
    end
  end

This lets you unit test your notify_expiring method on the account class and make sure that it’s doing what it’s supposed to do. This is a small, made up example, but you get the idea. Here’s an example from Resque:

  desc 'Restart redis'
  task :restart do
    RedisRunner.stop
    RedisRunner.start
  end

Notice the delegation to the RedisRunner class methods? This is a great rake task

Rails

You can get access to your models, and in fact, your whole environment by making tasks dependent on the environment task. This lets you do things like run rake RAILS_ENV=staging db:migrate. Rails will autmatically pick up tasks in lib/tasks. Any files named with the .rake extension will get picked up when you do rake -T.

Scheduling Rake Tasks

You can use cron to schedule rake tasks. Let’s say you wanted to run the account email expiration task every night at 12:15 on your production server, you might have something like this:

  15 * * * * cd /data/my_app/current && /usr/bin/rake RAILS_ENV=production accounts:email_expiring

Misc

Rake.original_dir gives you the directory that the original rake task was run from.


Derivatives

  • Thor is a more class based approach to solving some of the things rake does as far as actual tasks go.
  • Capistrano is the de facto standard for deploying rails apps. Its syntax is inspired pretty heavily by Rake, but it is definitely not rake.

Further Reading

Useful Rake Examples

If you have any more useful rake examples, please let me know and I’ll add them here.


Photo Credits: Shaker rake by dicktay2000 on Flickr.
Toy sampling megaphone by altemark on Flickr.