Avalanche Effect

Homebrew of polygons, startups, and a dash of coding bits.

Ranking Popular Items With Newtonian Cooling

Having implemented the Reddit ranking algorithm and Wilson Score, I’ve recently been fascinated with Evan Miller’s article on Ranking Hotness with Newton’s Law of Cooling because of its simplicity and ease of implementation.

What I like most about exponential decay:

Minimize writes to the database

You only need to write to the database when you’re incrementing the temperature. No longer need to run Cron jobs to constantly update the db.

Scale with site usage

As your site grows, the algorithm will scale with usage. It’ll only need minor modifications to your parameters to surface New/Popular items to your liking.

Easy to add more signals that influence popularity

When incrementing the temperature, it’s easy to add more signals such as commenting/sharing activity into the equation.

Here’s my simple code implementation in Ruby/Rails:

Easiest Ruby on Rails New Project Setup

Since RVM will install everything in it’s own directory and repoint your environment to the new installation, you won’t need to worry about prior failed installations of Ruby or Rails. In other words, you don’t need to uninstall everything and attempt a clean install.

On OS X, the key to setting up a Rails project is to use Homebrew to install MySQL and RVM to manage Rails. You’ll be running multiple rubies in seperate terminals concurrently in no time.

Switching Between Multiple Rails Environments

It’s hard to keep your project stable while still messing around with Rails 4.0. But switching between multiple Rails versions (3.2.12, 3.2.13.rc2, 4.0) became a breeze after reading Daniel Kehoe’s excellent Updating Rails.

Big Caveat

A lot of people have used Engine Yard’s RailsInstaller. Don’t use it. Although it’s great to get up and running right away, it’ll bite you hard in the ass in the future. It actually installs RVM at the system level (for all users, not in your usr directory) so your carefully tweaked configs won’t match when switching between project directories.

Fortunately, Rachel Ober has a great article on how to Uninstall OSX RailsInstaller.

Picking the Right Blogging Service

A lot has changed since my first WordPress blog.

Recently, I had the opportunity to decide on a new blogging service. Starting something from scratch without alot of prior dependencies is a rare opportunity. Although WordPress is taking over the interwebs as the gold standard, I’ve heard only good things about Octopress and Tumblr. There’s also Medium and Svbtle but these are invite-only and inflexible for organization blogs.

Once you pick a particular service it exposes you to huge switching costs. Here are my requirements with a heavy weighting on medium/long term objectives.

1) A Pleasure to Post

I want to focus on writing and not worry about mundane details. I don’t want to be gnashing my teeth on month nine. I want to write, post, and get back to work.

WordPress
Posting with their rich text editor never quite formats it the way I want it. The need to shift-enter or add a tiny ‘< br >’ is frustrating, not to mention the constant need to hop back and forth to preview the article. There’s an overwhelming and often unnecessary set of options for simple posting.

Tumblr
Posting is swift and simple out of the gate. Switch quickly to rich text, HTML, or Markdown. It’s like writing a quick email.

Octopress
A hacker’s wet dream. A huge learning curve for non-techies. For maximum mileage, it requires familiarity with command line (CLI), plugins, and general HTML5/CSS/Sass principles. And you’ll need to know Markdown. That said, say goodbye to malformed posts, constant adjustments with ‘< br >’, and switching between ‘HTML’ and ‘Visual’ tabs in the wp post editor to align content correctly.

Update: From @octopress: “CSS/Sass knowledge isn’t required for Octopress anymore than it is for Tumblr. Also posts can be HTML, Textile, Markdown, etc.” Very valid point.

Overall, Tumblr wins here. However, Octopress wins if you’re a hacker.

Upgrading to Ruby 2.0.0 With CarrierWave/RMagick

I had an issue today upgrading to Ruby 2.0.0 using CarrierWave/RMagick and rails s wouldn’t run. The steps are listed below to get it working again.

Upgrade Rails

In most cases, just change the Gemfile specification to:

1
2
source 'https://rubygems.org'
gem 'rails', '3.2.12'

Then run:

1
2
3
$ bundle update rails
$ rails -v
Rails 3.2.12

The Rails gem will be updated by bundler and the Gemfile.lock file will be updated to record the new gem version. You’ll see a message showing which version of Rails is running when you start the webserver.

Aiming Above Target

Some painters transform the sun into a yellow spot, others transform a yellow spot into the sun.

Pablo Picasso