Tech news, code samples, product reviews, etc.
Bookmarklet Loader is a template bookmarklet that injects your app’s .js and .css into the current page when clicked. You can grab the code on GitHub: Bookmarklet Loader Bookmarklet Loader is written in CoffeeScript, however bookmarklets must be JavaScript and URL encoded. CoffeeMarklet does a great job of converting CoffeeScript to bookmarklet-friendly JavaScript. I recommend you use it to...
I’ve slowly been learning how to test my Rails projects with Rspec and I thought it would be helpful to document this experience. I’m sure there are better, faster, smarter ways to test these concepts, so please do tell me in a comment so I (and others) can learn! To get started, make sure you have Rspec installed properly. Ryan Bates created a great Railscast that walks through setting up...
I decided to write a super lightweight endless scroll (a.k.a. endless page, pageless, without pagination, etc.) plugin for jQuery. It will let me trigger some code whenever the user scrolls within a certain number of pixels from the bottom of the page. I’ll get right to the juicy details. Here is the plugin code, and yes, it’s written in CoffeeScript. If you need javascript, feel free to copy...
Just about every time I start a new Rails project, I find myself building out a way to reference records based on a masked identifier. It just feels wrong to me to display the count of the number of records in the database, which is the Rails default. UPDATE: I created a Rails plugin that makes it easy to add a non-incrementing masked identifier to any ActiveRecord object. Check out the Github...
Note: I was not paid by Plugable to write this post-- I genuinely love their product. Have you ever wanted to run dual-displays with your MacBook Pro? With the Plugable USB 2.0 UGA Multi-Display Adapter, it's easy and affordable ($64.50 on Amazon at the time of this writing). But before we get into details, here is the finished product Yes, I know-- I have three displays hooked up. Why...
If you've created a moderately complex form in Rails, you've probably asked yourself the question: How do I display a validation error message that doesn't relate to a specific field on my form? The first solution you should consider is the "error_messages_for" helper. You can use "error_messages_for" in your view to display a quick and dirty summary of all validation errors. For example, the...
Want to reduce the size of your Heroku slug? Easy-- move your static assets to S3. Great, problem solved, but wait... What do you do with the static assets left in your repository? I found myself asking this question today... My first though was to use .gitignore, which would exclude the static assets from my git repository and in turn my Heroku slug. However, this approach would leave me without...
Let's talk Ruby access control basics... What is the difference between 'private' and 'protected' methods in Ruby? In Ruby, the primary difference between a 'private' and 'protected' method is that a private method cannot be called with an explicit receiver, while a protected method can. What is an 'explicit receiver', you ask? An explicit receiver is the object that is receiving a message...
Many web services charge recurring subscriptions. Unfortunately, ActiveMerchant does not support recurring payments with PayPal Website Payments Pro (US) out of the box. In this tutorial, we will add support for recurring payments to ActiveMerchant. Before we begin, let’s list what we’re using here: ActiveMerchant v1.7.0 PayPal Website Payments Pro (w/ Recurring Payments Enabled) Rails...
While working on an address form for a rails project, I came across this nasty little task of building an array of country, state, and province codes. I ended up downloading PayPal's official list of country, state, and province codes from their API documentation and making the following: Country codes: U.S. state codes: Canadian province codes: Other state/province codes: Hopefully this saves...
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing). The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here: Heroku Hostname SSL GoDaddy Standard SSL Certificate...