Trevor Turk

A chess-playing machine of the late 18th century, promoted as an automaton but later proved a hoax.

One-off steps in Cucumber

While I was busy complaining

I think I figured out what I don’t like about cucumber — you have to write a step for everything, even it it only pertains to a single test.

@smithcorona came up with a solution:

Nice.

Logging outgoing emails in Rails 3

Let’s say you want to have a log of all outgoing emails in your Rails 3 app. Thanks to some pretty sweet notification support in the Mail gem, it’s really simple. Here’s an example using Mongoid:

Initially, I was logging the entire contents of the email, but that included attachments as well. So, now I’m just logging the body. I wonder if there’s a better choice of what to log, though…

Any ideas?

Links for 2-1-11

I’ve cleaned out my GitHub watched repos quite a bit. My newsfeed just had way too much going on. Something needed to be done. Before cleaning things up, I decided to bookmark all of the repos I had been watching on pinboard:github. If you’re interested, have a browse through those links. There are some really great projects buried in there.

Top 10 Mistakes in Behavior Change

Today, Web Development Sucks

It’s hairy, scary, maybe even downright abominable. Here I’ll try and explain why I think our current tool chains are inadequate, and where I think we should be going to fix it.

Nate’s Blog – revealing the ActionController callback filter chain

Due to some fancy-pants metaprogramming in AbstractController::Callbacks, it’s hard to see what’s going on.

ETags with memcached // opensoul.org

While working on a Sinatra-based JSON web service that gets very heavy traffic, I wanted to find a way to short-circuit requests and avoid most of the stack if a resource hasn’t been modified.

Hacker News | Google algorithm change launched

Earlier this week Google launched an algorithmic change that will tend to rank scraper sites or sites with less original content lower. The net effect is that searchers are more likely to see the sites that wrote the original content. An example would be that stackoverflow.com will tend to rank higher than sites that just reuse stackoverflow.com’s content. Note that the algorithmic change isn’t specific to stackoverflow.com though.

Graham Wetzler: Why Dropbox Succeeded and Syncplicity Didn’t

Our company had too many features and this created confusion amongst our customer base. This in turn led to enough customer support issues that we couldn’t innovate on the product, we were too busy fixing things.

A List Apart: Articles: Never Use a Warning When you Mean Undo

Oh, and the next time you see a warning used instead of undo, send the designer of the application/website a nice e-mail suggesting that they implement an “undo” feature instead. Send them a link to this article. Let’s see if we can’t change the way people design on the web—and in the process make everyone’s computing life more humane and less frustrating in one little way. Let the war on warnings begin!

Operator billing – QuirksBlog

I hesitate to name 2011 the Year of Operator Billing, because there are many technical and political issues that must be solved before a unified system can be deployed across Europe and North America, and that’ll take more than a year. But operator billing is definitely coming.

Data Modeling in Performant Systems // RailsTips by John Nunemaker

Don’t should on yourself // opensoul.org

Should is a dangerous word. It conveys a sense of obligation. Failure to follow through with things you should do leads to guilt. Guilt is demotivating.

Newlee – HTTP Basic Authentication and Devise

Say you’re using Heroku to host a staging version of your app that uses Devise for authentication. You want to keep unwanted visitors out of your staging app, but your app only uses authentication for certain features. You want to block outsiders from accessing the app entirely. Since Heroku doesn’t allow you whitelist IP addresses in your webserver config, you might want to try HTTP basic access authentication to provide top-level authentication. Doing this in Rails is pretty straightforward.

Iterating Through Time With Rails — Andy Lindeman

While the #to_i calls look a bit unappealing, it’s important that Range#step is called over numbers, or else it would have to call #succ 86400 times between iterations!

What Larry Page should do as New CEO of Google

What I saw in Google’s WiFi´s effort were different “professors” running around with different ideas, trying to line up Google resources behind them only to rise and fall with unfinished projects. Initiatives like WiFi San Francisco, municipal WiFi throughout USA never took off because of lack of company wide support. And WiFi is but one example.

A Backbone.js demo app (Sinatra Backend)

Background Jobs with RabbitMQ and Minion

So if you’re comfortable with the concept of using a queueing system to run background jobs, and are ready to go to the next level of scalability, performance, and robustness, where to from here? It’s time to get your hands dirty with a serious queueing tool: RabbitMQ.

John Resig – Learning from Twitter

An issue popped up on Twitter this past week that caused the web site to be generally unusable for many users. It appears as if attempts to scroll were unbearably slow and caused the site to be unresponsive.

phil.sergi.blog: Testing Rake Tasks with RSpec

Not sure if this is the correct way to go about testing rake tasks but it works pretty well.

Update: A New & Improved jQuery Script to Automatically Preload images from CSS | Filament Group, Inc., Boston, MA

When we first launched the lab, we released a jQuery plugin that automatically preloads all images referenced in CSS files. We’ve found the script to be incredibly helpful in developing snappy applications where images are always ready when we need them. This post describes a significant update to the script which will make it even easier to integrate in existing projects.

Quick Left | Hoptoad + delayed_job

The Ambiguity of “Open” and VP8 vs. H.264 – Blog

Google has recently announced their intention to remove the H.264 video codec from its Chrome browser.

Ruby Conference 2010 Videos

Optimizely: A/B Testing you’ll actually use

Simple, fast, and powerful. Optimizely is a dramatically easier way for you to improve your website through A/B testing. Create an experiment in minutes with our easy-to-use visual interface with absolutely no coding or engineering required.

Rails 2.3.8, Rack 1.1 and the curious case of the missing quotes – Ruby on Rails, JRuby, AWS, EC2, Exalead

If you’re using Rails 2.3.8 for your application and thought that you were safe after May’s comedy of errors produced three point updates in as many days, think again. Unfortunately there’s a little bug that can lead to parameters being altered or potentially even truncated without warning.

Cory’s Ruby YUI Compressor v 2.0 Simpler, shorter. « Cory O’Daniel – These are just words

So, a while ago I write a Ruby YUI Compressor Wrapper which is still available and works great (although it could use a newer jar file) as far as I know… [but] on a new project I’m working on *I just need a inline YUI compressor* and I dont give a damn about anything else like bundling, globbing or whatever. So I ended up throwing together this little (~50 lines less comments) Ruby YUI Compressor to do my dirty work.

Jasmine: BDD for Javascript | Jasmine

Jasmine is a behavior-driven development framework for testing your JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.

Red Squirrel’s Nuts – Chicago’s Ruby Developer Crisis

Trying to hire Ruby developers in Chicago is hard right now. Really hard. Like, I think every single one of them is happily engaged in their work. This is great for Chicago Ruby developers. This is frustrating for people trying to ramp-up their teams with local Ruby talent. How did we get here? How do we get out of this problem?

TotalFinder

…brings tabs to your native Finder and more!

Using JavaScript/jQuery to update the browser window title bar

So, I have this little chat app that’s using the wonderful Pusher to support Websockets with a fall-back to Flash. If you’re interested in Websockets, I definitely recommend taking a look at Pusher.

Using Pusher to show new messages etc was the easy part. The tricky thing (for me, at least) was figuring out how to update the browser tab’s title. I wanted to show an unread messages count if the chat window was inactive. For example:


…versus:

When the chat window is made active again, the unread messages count should be gone.

Sounds easy, right? Well, it was, for the most part. The only catch was that I had to use setTimeout() to get things working reliably across browsers. I’m not sure why.

Anyway, here’s the relevant code:

Notify Hoptoad if there’s an exception in Delayed::Job

Here’s how to get Hoptoad notifications if there’s an exception raised while working through your queue in Delayed::Job:

via quickleft.com

delayed_job_admin: a simple admin interface for Delayed::Job

So, I just published my first Rails 3 gem engine: delayed_job_admin. Thanks very much to José Valim for his wonderful book and for enginex, which made creating this gem a breeze.

It’s a very simple (you might even say “unfinished”) admin interface for Delayed::Job.

Here’s a screenshot:

Right now, it only lets you view jobs in your work queue. If/when I have the need for more features, I’ll definitely add them into the gem. However, if you find that you like this interface and wish it did a bit more, please don’t hesitate to fork and the gem and send me a pull request!

Thanks to CaptainU for letting me open-source this little bit of code. If you’re looking for a gig working with Ruby, look no further – I hear they’re hiring now. Drop them a line and maybe we can hack on something together soon :)

Caching assets in a Rails 3 app on Heroku

In Rails apps, you often have multiple css and javascript files. If you’re using the “javascript_include_tag” and/or “stylesheet_link_tag” helpers, you can let Rails automatically package multiple files into a single file by using the “:cache => true” option. I’m sure you’re already aware of this, but if not, you can read more about it here.

A problem arises when trying to deploy an app using this technique to Heroku due to their read-only filesystem constraint. If you’re familiar with Yahoo’s Best Practices for Speeding Up Your Web Site and related YSlow tool, you know that caching your assets is an important part of having a speedy site.

There are a lot of possible solutions to this problem hanging around, but none of them seemed 100% ideal for my situation. So, I asked if there is a preferred method of caching/packaging assets in a Rails 3 app on Heroku in the Heroku Google Group. Nothing much came up, so I did a bit of Googling and came across this Stack Overflow page that pointed me in the right direction.

I’ve written a couple of small rake tasks that have been working quite well for me. The first is the “rake deploy” task. So, now I use “rake deploy” instead of “git push heroku master” when I want to deploy to Heroku. This caches my assets, pushed to github, deploys to heroku, and notifies hoptoad about the deploy.

But the “rake cache_assets” task is what we’re really interested in here. This leverages the built-in functionality of Rails to cache your assets, so it works exactly as you’d expect. It’ll create the “all.js” and “all.css” automatically, because I’m using the “:cache => true” option in my helpers. It’ll commit those files (if they’ve been changed) and then when I set “config.action_controller.perform_caching = true” in my “config/environments/production.rb” file, my app will use the cached files automatically.

This is a great first step, but there’s still more that can be done. As Heroku’s David Dollar pointed out in the Google Group, one could package these assets up and upload them to S3, using CloudFront as a CDN, and telling Rails to use that as your asset host. I’ve talked about CloudFront before, and I’ve had nothing but positive experiences with it, so I might try this in the future (uploading to S3 with fog, of course). If you’re interested in collaborating on this, please drop me a line.

Links for 1-13-11

Let’s celebrate the new year with the first round of links from my new account on Pinboard. I’ve decided to move away from Delicious due to fear, uncertainty, and doubt that the service may be shutting down. See Yahoo!locaust for more information on that subject.

I’ve been very happy with Pinboard so far, and would highly recommend it as an alternative to Delicious. They even have a handy Delicious->Pinboard importing feature to help get you started. It’s much faster, more pleasing to the eye, and seems to be actively maintained by smart people. It’s a win all around.

This also means that I have a new way of getting at my links for publishing here. I whipped together a quick Rake task based on some code I found while Googling around. It’s nothing special, but it seems to get the job done:

…it works, you know?

So, this set of links includes a bunch of stuff I cleared out from my GitHub watch list, which had gotten a bit overwhelming. I subscribe to my private GitHub RSS feed in Google Reader to help me keep up with the projects I’m interested in, and checking that on a weekly basis works well for me. Still, it was time to do a little spring cleaning… in the dead of winter… I suppose… :)

So, without further ado:

Campaign for Real Ale

CAMRA campaigns for real ale, real pubs and consumer rights. We are an independent, voluntary organisation with over 100,000 members and have been described as the most successful consumer group in Europe. CAMRA promotes good-quality real ale and pubs, as well as acting as the consumer’s champion in relation to the UK and European beer and drinks industry.

brianmario/streamly – GitHub

A streaming REST client for Ruby, using libcurl

hckr news – an unofficial, alternative Hacker News interface

Hacker News is a great resource. However, I seemed to constantly run into two issues. 1. If I didn’t visit at least once a day, top items would scroll off the top pages and I would never see them. 2. If I was procrastinating and visiting the page often, I would find it difficult to determine what was new on the page. That frustration led to hckr news, a chronologic list of items that have made it onto the Hacker News homepage.

5 Better Ways to Read “Hacker News”

Hacker News is one of our favorite places to find interesting stories, learn about apps and side projects from the dev community and stay connected to the early stage startup scene.

10 Simple Truths Smart People Forget

Some of the smartest people I know continuously struggle to get ahead because they forget to address a few simple truths that collectively govern our potential to make progress.

The Untitled Blog: Google Chrome “Feeling Lucky Search”

If you want to do a “Feeling Lucky” search from Google Chrome post haste, I’ve got a great trick for you.

How To Ensure Your Email Gets Delivered | Engine Yard Ruby on Rails Blog

It goes without saying that email is the de facto method by which online businesses communicate with users and clients; without a doubt, it’s a necessary and core function of business today. That being the case, how does a business know that its  email is actually getting delivered?

nathancolgate/s3-swf-upload-plugin – GitHub

A rails 3 gem which allow user upload files to S3 through an embedded flash directly. All UI has been moved out of flex and can be controlled by CSS and JavaScript callbacks.

ernie/meta_where – GitHub

ActiveRecord 3 query syntax on steroids.

jamesgolick/friendly – GitHub

NoSQL with MySQL in Ruby

pivotal/refraction – GitHub

Rack middleware replacement for mod_rewrite

anveo/swfupload_demo – GitHub

How to use SWFUpload with custom Rack Middleware

jtrupiano/rack-rewrite – GitHub

A web server agnostic rack middleware for defining and applying rewrite rules. In many cases you can get away with Rack::Rewrite instead of writing Apache mod_rewrite rules.

clint-tseng/Awesomecomplete – GitHub

A lightweight Autocomplete plugin for jQuery. Autocomplete that doesn’t suck — I think.

wp_ar.rb at master from jystewart/wp_ar – GitHub

ActiveRecord models to work with WordPress databases

sunlightlabs/rack-honeypot – GitHub

Middleware that functions as a spambot trap. Cast spambots off into the abyss.

tobi/imagery – GitHub

Image server / proxy that can resize images on demand based on common file prefixes ( such as _small, _medium ) and apply other rmagick effects. Supposed to be used between a Squid/Varnish and S3

ifunk/swfupload-jquery-plugin – GitHub

A jQuery plugin that makes working with SWFUpload even easier.

lardawge/swfupload-rails-authentication – GitHub

Demo Rails 3 app showing SWFUpload working in tandem with restful-authentication, CSRF protection and paperclip.

kabuki/heresy – GitHub

Heresy is a schema free wrapper around your database, heavily inspired by both CouchDB and FriendFeed.

enriquez/ezpz-hint – GitHub

A simple jQuery plugin for showing a text field’s label inside the textbox itself. The hint disappears when it is given focus, and appears again if the inputted text is empty. Typically used for search and login forms.

patientslikeme/campaign_monitor – GitHub

Ruby gem for accessing the Campaign Monitor API with support for new API keys, hex IDs, and custom subscriber fields

pillowfactory/csv-mapper – GitHub

A small library intended to simplify the common steps involved with importing CSV files to a usable form in Ruby

Startups and The Problem Of Premature Scalaculation

Don’t fall into the trap of spending your limited resources on planning and preparing for success. Instead, spend them on things that will actually increase your chances of success.

The Web Is a Customer Service Medium (Ftrain.com)

“Why wasn’t I consulted,” which I abbreviate as WWIC, is the fundamental question of the web. It is the rule from which other rules are derived. Humans have a fundamental need to be consulted, engaged, to exercise their knowledge (and thus power), and no other medium that came before has been able to tap into that as effectively.

PostgreSQL performance considerations – GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS

There are a number of variables that allow a DBA to tune a PostgreSQL database server for specific loads, disk types and hardware. These are fondly called the GUCS (Global Unified Configuration Settings) and you can take a look via the pg_settings view. There are also a few of things that you can do in your application to get the most out of Postgres

Marco.org – Google’s decreasingly useful, spam-filled web search

Much of this will be (or currently is) solved the old-fashioned way: personal recommendations and trusted authorities. But these can’t cover the breadth of available information that web searchers need. I don’t know what will, or when, but it’s desperately needed.

paperplanes. The Virtues of Monitoring

On today’s menu: monitoring. People have all kinds of different meanings for monitoring, and they’re all right, because there is no one way to monitor your applications and infrastructure. I just did a recount, and there are no less than six levels of detail you can and probably should get. Note that these are my definitions, they don’t necessarily have to be officially named, they’re solely based on my experiences. Let’s start from the top, the outside view of your application.

How and why did Amazon get into the cloud computing business? – Quora

Rumor has it that they wanted to “lease” out their excess capacity outside of the holiday season (Nov-Jan). Is that true?

ddollar/shoebox – GitHub

Shoebox helps you manage styles and scripts as first-class citizens in Rails.

fusedevice/nginx-control – GitHub

Nginx control script

jnunemaker/crack – GitHub

Really simple JSON and XML parsing, ripped from Merb and Rails.

pauldix/feedzirra – GitHub

A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all.

mamuso/acts_as_unvlogable – GitHub

An easy way to include external video services in a rails app.

gabriel/shrub – GitHub

S3 Proxy for Google App Engine

vigetlabs/simple_importer – GitHub

Simple API for importing from csv.

svenfuchs/adva_cms – GitHub

cutting edge cms, blog, wiki, forum

cpjolicoeur/bb-ruby – GitHub

BBCode implementation for Ruby

joshfrench/rakismet – GitHub

Easy Akismet and TypePad AntiSpam integration for Rails

couchrest/couchrest – GitHub

A RESTful CouchDB client based on Heroku’s RestClient and Couch.js

ntalbott/query_trace – GitHub

Adds query origin tracing to your logs.

seangeo/ratom – GitHub

A fast, libxml based, Ruby Atom library supporting the Syndication Format and the Publishing Protocol.

sr/ape – GitHub

The Atom Protocol Exerciser

jnicklas/liability – GitHub

Asset packaging Rack middleware

lifo/cramp – GitHub

Asynchronous ruby framework for realtime web applications

plataformatec/mail_form – GitHub

Send e-mail straight from forms in Rails with I18n, validations, attachments and request information.

akdubya/rack-thumb – GitHub

Drop-in image thumbnailing for your Rack stack

zilkey/active_hash – GitHub

A readonly ActiveRecord-esque base class that lets you use a hash, a Yaml file or a custom file as the datasource

maccman/remail – GitHub

Forget configuring SMTP servers and queues, just use Remail. Remail uses Google App Engine to send and receive emails RESTfully.

tenderlove/texticle – GitHub

Texticle exposes full text search capabilities from PostgreSQL, and allows you to declare full text indexes. Texticle will extend ActiveRecord with named_scope methods making searching easy and fun!

ddollar/rack-debug – GitHub

Rack::Debug is middleware that provides a simple interface to ruby-debug. Helps debug apps running in Passenger.

radar/rboard – GitHub

A fully featured forum system compatible with Rails 2.3

rtomayko/rack-cache – GitHub

Real HTTP Caching for Ruby Web Apps

technoweenie/faraday – GitHub

Experiments in a rest api lib.

dejan/auto_html – GitHub

Rails plugin for transforming URLs to appropriate resource (image, link, YouTube, Vimeo video,…)

mockko/livereload – GitHub

LiveReload applies CSS/JS changes to Safari or Chrome w/o reloading the page (and autoreloads the page when HTML changes)

raggi/async_sinatra – GitHub

A plugin for Sinatra to provide a DSL extension for using Thin for asynchronous responses.

Rails 3 Cheat Sheets

Some of these sheets may be a review if you’ve already been working with Rails 3 for a few months now, but they’re great if you’re just now getting the hang of it or you want a good reference guide.

Hacker News | Ask HN: What are the best technologies you’ve worked with this year?

So HN, what are some cool, shiny new technologies that you worked with this past year? Care to tell us what those technologies are and why they are so cool?

Build apps not businesses

It’s fun. It’s fast. It’s the ultimate resume.

URL Design

If there’s one thing I hope you remember after reading this article it’s to take time to design your URL structure. Don’t leave it up to your framework. Don’t leave it up to chance. Think about it and craft an experience.

Yahoo!locaust

Two graduate students, intrigued by a growing wealth of material on the Internet, built a huge fucking lobster trap, absorbed as much of human history and creativity as they could, and destroyed all of it.

strfti.me: a strftime format reference and sandbox for ruby, python, php

Ruby, Python, C, and PHP programmers: format dates and times with strftime

Ron Burk: Cash Cow Disease: The Cognitive Decline of Microsoft and Google

Cash cow disease arises when a public company has a small number of products that generate the lion’s share of profits, but lacks the discipline to return those profits to the shareholders.

sferik/rails_admin

RailsAdmin is a Rails 3 engine that provides an easy-to-use interface for managing your data

Facebook | Visualizing Friendships

After a few minutes of rendering, the new plot appeared, and I was a bit taken aback by what I saw. The blob had turned into a surprisingly detailed map of the world.

Scopes Are Obsolete

Stop replicating functionality that already exists, stop using scope. It is obsolete.

A Cure for Hacker News Overload

One strategy for consuming Hacker News is to periodically check the top stories on the home page since that’s where most of the high-scoring articles reside. This works okay if you’re always in front of the computer, but if you’re away, you miss out. It’s also terribly inefficient to repeatedly check HN, because you have to rescan stories you’ve already seen.

What’s wrong with OpenID? – Quora

The short answer is that OpenID is the worst possible “solution” I have ever seen in my entire life to a problem that most people don’t really have.  That’s what’s “wrong” with it.

Deploy to Heroku and notify Hoptoad

You can add your own custom steps to this Rake task if necessary:

Getting the last commit hash in Git

Getting the last commit id (or hash or sha or whatever it’s called) is a bit more tricky than I expected:

git log master -n 1 --pretty=format:%H
Follow

Get every new post delivered to your Inbox.