Rails Caching Strategies (a presentation)


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Tonight I gave a presentation at the Rails Meetup in Seattle on caching strategies with Rails, and I had a great time. I’m convinced Rails developers don’t use caching enough, and we have so many good options for caching in our apps, we really should be avid practitioners of caching. 🙂

I had a request to put my slides up, so here they are. They are a bit more useful if you have the context of the words I said along with them, but that’s the way these things go, right?

For those of you who were there, I suppose I should apologize for mentioning (so many times) the Airbrake competitor that I recently launched. After the 2nd or so time I mentioned it, it became a bit of a joke to see how many times I could mention it, and I do hope I didn’t annoy you. 🙂

Looking for Ruby and Rails developers


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




I’m on the hunt for development help, so if you’ve been working with Ruby and/or Rails for a while, and you’re looking for some contract hours to fill, I’d love to hear from you.

A fellow entrepreneur here in Seattle and I both need someone part-time, so between the two of us, we might be able to use all the hours you can spare. We’re both open to intermediate through advanced Ruby/Rails developers, with hourly prices from $60 to $120, with at least 10 to 20 hours available per week. Both of us are looking to work with a developer for an extended period of time, so this could be the beginning of a beautiful friendship. 🙂

My needs include getting help with RailsKits, and Catch the Best. If you end up helping me with RailsKits, that could lead to additional engagements, as I’m often getting requests from people looking for development help to tweak the Kits to meet their needs.

My entrepreneur friend is looking for help for his bootstrapped startup, which is in the early part of its development cycle. If you are on the more advanced end of the spectrum he’ll be looking to you to help coordinate the efforts of more junior developers, which means you’ll be able to focus on the bits you find interesting. 🙂

I won’t bore you with a required skills list – if you’ve been developing web apps for at least a year or two, then you’ll be comfortable with (or be able to quickly learn) the whole stack of technologies that we are using.

To get in touch and let us know you’d be interested in us throwing cash at you in exchange for your talents, please submit your info here. Be sure to include a link to your github profile, a brief run-down of your relevant experience, and your desired hourly rate. This is a contract/1099 arrangement.

Missing attr_unsearchable in ransack?


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




If you are upgrading to ransack from meta_search, and you are missing being able to use attr_unsearchable to hide various model methods from search, you can add this to your model instead:

def self.ransackable_attributes(auth_object = nil)
  (column_names - ['company_name']) + _ransackers.keys
end

In this case, company_name will no longer be searchable with the dynamic scopes that ransack creates.

Easy mobile device login for Rails apps


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




I read an article this morning on TechCrunch about an upcoming service that makes it easy for developers to add mobile logins to their web applications, and I thought I’d try something similar for a new project I’m working on.

If you use the Devise gem for managing logins for your Rails app, and you pass the :token_authenticatable to the devise method, then your users can log in with a link that includes an authentication token, bypassing the email/username and password login. With that in place, all you need to do is generate a QR code that encodes a link to your app with this authentication token included. Here’s how you can do that:

Following the instructions of the qr code gem, install the gem by adding gem 'rqrcode' to your Gemfile and running bundle install. Generating the code can be done in a HAML view like so:

- qr = RQRCode::QRCode.new(root_url(Devise.token_authentication_key => current_user.authentication_token), :size => 10, :level => :l)
%table
  - qr.modules.each_index do |x|
    %tr
      - qr.modules.each_index do |y|
        %td{ class: qr.dark?(x,y) ? 'black' : 'white' }/

This assumes that you have devise hooked into your User model, and the currently-logged in user is available to the view via the current_user method. Using the CSS from the rQRCode home page, this will display a QR code that can be scanned on a phone.

This will allow a user to log in to your app (using their laptop), scan the QR code on their phone, and then be logged in on their mobile browser. Easy. 🙂

Print Progress Bar Background Color in Chrome


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




I’m working on a project today that uses Twitter Bootstrap, displays progress bars, and has a requirement to print those progress bars. Sadly, Chrome doesn’t like to print background colors by default, so printing the progress bars didn’t work so well. Here’s the trick to get it to work: -webkit-print-color-adjust:exact. This instructs Chrome to print the background color.

After that, adding a few more styles (in a print stylesheet) makes for nice-looking progress bars (SCSS):

.progress {
  background-image: none;
  -webkit-print-color-adjust: exact;
  box-shadow: inset 0 0;
  -webkit-box-shadow: inset 0 0;

  .bar {
    background-image: none;
    -webkit-print-color-adjust: exact;
    box-shadow: inset 0 0;
    -webkit-box-shadow: inset 0 0;
  }
}

Googlebot Gotcha


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Did you build your site thinking that googlebot can’t understand your javascript? I did, and I was a bit surprised when I learned I was wrong…

Continue reading “Googlebot Gotcha”

Skipping Asset Compilation with Capistrano


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Capistrano has a handy task that runs rake assets:precompile for you when you are deploying your Rails 3.1 application. This gives you an easy way to get the performance boosts of having only one css file and one javascript file to load per request. The price you pay for that benefit is the amount of time it takes to run that rake task when you are deploying. There is a way to get the benefit while reducing that cost, though.

Since capistrano creates a symlink for the assets that is moved across deploys, you really don’t need to compile those assets for any deploy where the assets didn’t change. Instead, all you need to do is move the symlink. However, the default capistrano for compiling the assets does compile them every time, regardless of whether any assets were changed in the set of commits that you are deploying. The trick, then, is to check the list of files that were changed in the range of commits that are being deployed, and compile the assets only if assets show up in that list. And here is a code snippet that does exactly that:

It only supports git, as that’s what I use, so if you use git, just drop that snippet into deploy.rb and enjoy quicker deployments.

Skipping Asset Compilation with Capistrano


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Capistrano has a handy task that runs rake assets:precompile for you when you are deploying your Rails 3.1 application. This gives you an easy way to get the performance boosts of having only one css file and one javascript file to load per request. The price you pay for that benefit is the amount of time it takes to run that rake task when you are deploying. There is a way to get the benefit while reducing that cost, though.

Since capistrano creates a symlink for the assets that is moved across deploys, you really don’t need to compile those assets for any deploy where the assets didn’t change. Instead, all you need to do is move the symlink. However, the default capistrano for compiling the assets does compile them every time, regardless of whether any assets were changed in the set of commits that you are deploying. The trick, then, is to check the list of files that were changed in the range of commits that are being deployed, and compile the assets only if assets show up in that list. And here is a code snippet that does exactly that:

It only supports git, as that’s what I use, so if you use git, just drop that snippet into deploy.rb and enjoy quicker deployments.

Deploying New Relic Server Monitoring with Chef


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




This morning I deployed New Relic’s new Server Monitoring feature for the first time (I’ve used Scout previously). It’s cool to see your server vitals right next to all your app vitals, and their interface looks attractive, to boot.

Since I deploy everything with Chef, I threw together a quick Chef recipe to automate the installation of New Relic’s server monitoring agent. It has been tested with Ubuntu 10.04 LTS, and you can configure the license key in your Chef JSON config.

You can grab the recipe from my Chef recipe repository at Github.

Improvements to Bundle Watcher


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




I just released an update to Bundle Watcher this morning that may make it a little easier to get your Ruby gem updates tracked. Now you can specify a URL where your Gemfile.lock resides, rather than having to upload a file.

You can also now see a list of bundles that your tracking, once you’ve logged in via Github. This list shows you at a glance which gems have been updated for your bundles.

Improvements to Bundle Watcher


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




I just released an update to Bundle Watcher this morning that may make it a little easier to get your Ruby gem updates tracked. Now you can specify a URL where your Gemfile.lock resides, rather than having to upload a file.

You can also now see a list of bundles that your tracking, once you’ve logged in via Github. This list shows you at a glance which gems have been updated for your bundles.

Faker 1.0 released


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Earlier this week I released version 1.0 of the Faker gem. It’s been about 4 years since the initial release of the gem, and the API has been fairly stable for the last couple of years, so I figured it was a good time to make the jump to 1.0. 🙂

This release finishes the conversion to I18n. Just about everything is in the locale files now, including the ability to define custom formats for everything — company names, street addresses, etc. And, with the magic of method_missing, you can add new items to your locale file and have them show up as methods in the Faker classes.

The 1.0 release also settles some long-standing issues people have had with bad interaction between Faker, Rails 2.3, and locales (especially fallbacks). Though I’m not actively seeking to support Rails 2.3, I at least don’t want it to be broken, so this release should cover that. Both Ruby 1.9.2 and 1.8.7 are fully supported.

Finally, I want to send out a big “thank you” to everyone (and there are a lot of them) who contributed code and ideas to this release. I really appreciate the interest shown and the work done by so many people who use and love Faker. According to rubygems.org, it has been installed over 400,000 times — over 1,000 times in the past few days!

Of course, I’m not done yet… next on the feature list is Faker::Image, which will provide an interface to all those cool fake image generator services out there. 🙂

CentOS 5.5 net install secret


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Today I needed to spin up a VM with CentOS 5.5. My preferred distro these days is Ubuntu, and I had to learn the CentOS dance to get an unsupported version installed, so it took me a little longer than I would have liked to get it going. Here’s the secret:

When asked for the name and directory of the install image, enter vault.centos.org for the name and 5.5/os/x86_64 for the directory. If that doesn’t work for you, go back a step and disable IPv6. After that, you should be good to go.

CentOS 5.5 net install secret


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Today I needed to spin up a VM with CentOS 5.5. My preferred distro these days is Ubuntu, and I had to learn the CentOS dance to get an unsupported version installed, so it took me a little longer than I would have liked to get it going. Here’s the secret:

When asked for the name and directory of the install image, enter vault.centos.org for the name and 5.5/os/x86_64 for the directory. If that doesn’t work for you, go back a step and disable IPv6. After that, you should be good to go.

BundleWatcher: Watching Your Gems


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




My weekend project this weekend was BundleWatcher, a tool that does just one thing: watches the gems in your Gemfile for updates. Once you upload your Gemfile.lock file, BundleWatcher will keep track of updates to the gems upon which your project depends, and you can use the atom feed for your bundle to know when updates have happened.

I built this to scratch my own itch. While rubygems.org provides a way to subscribe to gem updates and an RSS feed to track those updates, I wanted a way to track updates for each of my projects, project by project. Now instead of just knowing that the inherited_resources gem got updated, I can see which of my projects might need an update because that gem got updated.

BundleWatcher uses the (fantastic) API provided by rubygems.org to keep track of gem updates, so as long as you depend on gems that are listed there, you’ll be good to go.

Chef Tips


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




One of the best things that came out of using EngineYard Cloud was learning about Chef. Chef has changed my world when it comes to managing servers, and I now wouldn’t do any amount of system administration without the kind of automation and scriptability Chef provides. Here are a couple of tips on the reasons for and the benefits of using Chef.

Continue reading “Chef Tips”

Chef Tips


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




One of the best things that came out of using EngineYard Cloud was learning about Chef. Chef has changed my world when it comes to managing servers, and I now wouldn’t do any amount of system administration without the kind of automation and scriptability Chef provides. Here are a couple of tips on the reasons for and the benefits of using Chef.

Continue reading “Chef Tips”

Jekyll: Pagination, Archives, and Excerpts


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




I recently converted this blog to jekyll — I figured since I had to move my slicehost slices elsewhere anyway, I might as well ditch wordpress and play with something new. It’s been a bit of adventure getting the site rendered by jekyll to match the URL structure I had in place with wordpress, so I thought I’d share some of the code I found and wrote to make it work.

Continue reading “Jekyll: Pagination, Archives, and Excerpts”

Heroku at RailsConf in Baltimore


This post is by Ben from Heroku


Click here to view on the original site: Original Post




Baltimore, Here We Come!

Next week is RailsConf in Baltimore, and Heroku is coming out in force. There will be about a dozen of us attending sessions, manning our booth, and chatting with Rubyists, so definitely keep an eye out for us!

To make it a bit easier, here’s a quick summary of when and where we’ll be:

Monday, May 16th

  • At 6pm, Ben Scofield will be part of the second annual Ignite RailsConf. He’s giving a five-minute talk on How To Be Awesome (From a Counter-Example).

Tuesday, May 17th

  • The Expo Hall opens up Tuesday morning, so you’ll be able to visit the Heroku booth to find us, talk about deployment, and grab some swag. We’ll be around from 10-11:15, 12:35-2:15, and 3:25-4:55 (basically, whenever the Hall is open). We’ll also be giving mini-talks during each session – on RabbitMQ, Procfile and Foreman, database tracking and forking, and more.
  • The Add-ons team will be available all day to meet with add-on providers — both current and prospective. If you’ve been thinking about joining the Provider Program, be sure to grab one of their easily-identifiable green shirts and have a chat.

Wednesday, May 18th

Thursday, May 19th

  • The Expo Hall is closed on Thursday, but we’ll still be around — just look for us in sessions and in the halls, and we’ll be happy to chat.

Pricing Experiment Follow Up


This post is by Ben from BenCurtis.com


Click here to view on the original site: Original Post




Thanks so much to those of you who helped me with my pricing experiment. I feel it was a success, with a lot of great feedback.

Before I launched the survey I had a price in mind, but I wanted to see what the prevailing opinion would be on what the price should be without being influenced by that info. I was pleasantly surprised to find that many of those who responded were willing to pay more than the amount I had in mind, which makes me feel good about the value of the products I offer via Rails Kits.

The OAuth Kit has now been priced and released, but I’ll leave the survey open a little longer to let a few more folks get the coupon. 🙂