Why waste time carrying out repetitive tasks that a computer can do for you? You'd be better off spending your time programming (or doing some more of whatever it is that you do). A computer will make a better job of it than you too.
To quote the The Pragmatic Programmer (which, incidentally, is highly recommended reading):
People just aren't as repeatable as computers are. Nor should we expect them to be. A shell script or batch file will execute the same instructions, in the same order, time after time. -- The Pragmatic Programmer, pg. 231
Whenever I have to repeat a task I usually write a quick script for it. I like to use the right tool for the job, and quite often that's Bash. In a world where Python and Ruby (et al.) are infinitely trendier I make no apologies for this – when you just want to string together a few Unix commands a shell script beats them hands down. Simplicity is a beautiful thing.
The articles that follow cover scripts that might be of use to a wider audience. Here's hoping that you find something in here that's useful...
When was the last time you finished some web development work (on your shiny, modern operating system) only to find that it didn't work in IE8. Or in IE9. Or a reasonably recent version of Opera. If you're developing web sites profesionally, you need to test them in multiple browsers running on multiple operating systems. I used to maintain virtual machines running Windows that could connect to my local dev server. These days I use BrowserStack.
On the face of it, deploying a Rails app to Heroku is very simple. You just push your Git repository to Heroku, then sit back and watch. Unfortunately it's not quite that simple when you need to put the site into maintenance mode, migrate the database, and then disable maintenance mode again.
Bundler is a great way to control the versions of the gems that are used in your Ruby application, but it requires you to run Ruby scripts and tools (such as
heroku) by prefixing them with an extra command (e.g.
bundle exec rake). This is a pain, can be easy to forget, and can cause no end of subtle bugs if the script that you're running can be found outside of the bundled application, in your shell's PATH.
Stoyan Stefanov has recently written an interesting series of articles on optimising image files for the web. In his latest article he shows how to use pngcrush to safely shrink your files, one file at a time.
I've recently been developing a Rails app that relies on a database that is maintained by another team as part of a different application. As you can imagine, unexpected changes to the database schema can bring our Rails app to it's knees if they're deployed to the live server before our application is updated.
I've been trying to persuade
git-svnto work properly with Rails plugins that are installed via
svn:externals. Whilst working out how to do it I stumbled across several great articles, but I couldn't get any of the solutions presented to work perfectly.
After a bit of head scratching I got it sorted, and wrapped the process up in a little utility called git-me-up.
I used to work for a company that was in the business of deploying laptops running Linux into hospitals. We automated the installation of these laptops to such a degree that all we had to do build a new laptop was unwrap it, plug it into an ethernet network and turn it on. We used PXE boot and our own bespoke deployment system to achieve it. It even supported deploying automatic configuration updates over a mobile phone connection, while the laptops were in a different country.
It never seems to be worth going to the effort to setup a tool like puppet when configuring a new desktop computer, a virtual server to run your blog, or a VPS for a small client who is keen to keep the budget down. But why should automation be expensive?
If you like the idea of an automated server build on the cheap, read on...