Rails Reading - November 15, 2009

Parking Cube and Tree

Ruby in a Nutshell… - philip hallstrom

This may not be very scientific, but perhaps this is why Ruby is such a wonderful language.

Google Code Blog: Use compression to make the web faster

Every day, more than 99 human years are wasted because of uncompressed content. Although support for compression is a standard feature of all modern browsers, there are still many cases in which users of these browsers do not receive compressed content. This wastes bandwidth and slows down users’ interactions with web pages.

RubyPulse :: Episode 0.18 - backtracer - "Quality output when an exception is thrown and not caught in Ruby." - rdp

Quality output when an exception is thrown and not caught in Ruby

InformIT: Refactoring Ruby: An Interview with Jay Fields > Refactoring Ruby: An Interview with Jay Fields

Neal Ford interviews Jay Fields about his new book with Shane Harvie and Martin Fowler, Refactoring: Ruby Edition, why they wrote the book around Ruby and not Dynamic Languages in general, and why he’d take a powerful language over a powerful tool anyday.

RailsLab .:. Scaling Rails - Episode #20 - On The Edge - Part 2

In this screencast we discover what typically causes Ruby server memory bloat, namely instantiating too many ActiveRecord objects. Thankfully there are several plugins which can help you detect when your application needs some help, and where your application is hurting the most. We start by taking a look at Rack-Bug, a toolbar which places all sorts of statistics about each requests at your fingertips. Next, we look at two libraries to help specifically track memory bloat; Memory Logic and Oink.

What Makes Ruby Go: An Implementation Primer

A walkthrough of how common and popular Ruby features are actually implemented, with a focus on how they work, why they behave the way they do, and why they do or do not perfom well. If you’d like to better understand What Makes Ruby Go, this is the talk for you.

A ‘When Rails Fails’ Follow-up « I am Zef

About 18 hours ago I posted When Rails Fails, in which I showed what happens if you make simple mistakes in your Ruby on Rails code. The response was pretty massive. 30 comments were left on the post itself, and more discussion takes place on reddit and hacker news, plus I received some messages on twitter. Most memorable is this one.

Using the Rubygems Bundler for Your App | Engine Yard Blog

The new Rubygems bundler makes managing your application’s gem dependencies easy. And for applications with many components, it makes separating components’ dependencies easy too.

Let’s start off with a simple, two-part application. Part 1 is a Sinatra app that puts JSON-serialized messages into an AMQP queue. Part 2 is a daemon that consumes those messages.

Extreme JavaScript Performance

You serve up your code gzipped. Your caches are properly configured. Your data (and scripts) are loaded on-demand. That’s awesome—so don’t stop there. Runtime is another source of slowdowns, and you can learn to conquer those, too.

Learn how to benchmark your code to isolate performance issues, and what to do when you find them. The techniques you’ll learn range from the normal (function inlining) to the extreme (unrolling loops).

Consuming XMPP PubSub in Ruby - igvita.com

Having personally struggled in the past with XMPP PubSub and Ruby, it’s been great to revisit the use case and find a new set of fully functional libraries. The event driven architecture which is enabled by technologies such as XMPP, AMQP, Comet, Webhooks and PubsubHubbub are increasingly becoming the staple of many web applications, and for a good reason. If you haven’t already, grab switchboard or blather and take XMPP for a test drive.

PaulBarry.com - Performance Testing with Httperf

If you need to do some performance testing of your web app, one tool that is pretty easy to use is httperf. I recommend watching the Peepcode screencast on httperf to get some good tips on how to doing performance testing. There is also some reading material on httperf created by Ted Bullock available. These are great resources, but here’s the quick and dirty on how to get httperf going.

Refactoring: Introduce Local Extension in Ruby | Vita Rara: A Life Uncommon

I was recently reading Martin Fowler’s Refactoring. While I was reading Introduce Local Extension (p. 164) all I could think of was how simple it is to implement in Ruby.

Motivation

As Fowler says in the motivation section writers of classes and libraries are not omniscient. Inevitably some class that you’re using will be missing some feature you want. Using Introduce Local Extension you can add that additional functionality when you need it.

In a statically typed language, like Java, this refactoring would involve creating either a wrapping class or a descendent of the original class. In Ruby we will accomplish the same thing using a mixin.

10 little known ways to find a ruby on rails team for your next project | Vinsol

Everytime we talk to our clients, we find that they are not aware of lot of options through which they can find a good rails developer. Usually clients go to odesk and other freelance websites to find rails developers. Following are 10 more ways to find rails company/developer for your next dream project :

litany against fear ¤ by nick quaranto ¤ Load Rails conditionally with Rack

One of the great things about Gemcutter is that it’s using Sinatra via Rails Metal to serve up the gems. Recently, I had to run some long migrations (~10 minutes) and I’m sure we’ll have some more in the future. Since the gem server is decoupled from the Rails app, some clever Rack loading now allows us to continue to serve gems even when we’re down for maintenance.

Mail: An All New Ruby E-mail Library

To date, the main ways to send e-mails from Ruby have been Net::SMTP, TMail, and Rails’ ActionMailer (which uses TMail). Now, however, there’s a fourth option, the simply named “mail” by Mikel Lindsaar.

Barking Iguana: Returning explicitly is slower

My main concern about returning explicitly is readability. It’s a very subjective thing, but in general whenever I see an unnecessary return statement my internal WTF counter increments.

Less subjective though, it has been pointed out that returning explicitly is slower.

How to Make a US County Thematic Map Using Free Tools | FlowingData

There are about a million ways to make a choropleth map. You know, the maps that color regions by some metric. The problem is that a lot of solutions require expensive software or have a high learning curve…or both. What if you just want a simple map without all the GIS stuff? In this post, I’ll show you how to make a county-specific choropleth map using only free tools.

and another thing… - absolute dates make tests brittle

Plan A is to create your test data with dates and times relative to when the tests are being run. You can do that in yaml fixtures by embedding ruby in the yaml:

published_at: <%= 2.days.ago.to_s(:db) %>

created_at: <%= 3.days.ago.to_s(:db) %>

updated_at: <%= 2.days.ago.to_s(:db) %>

Barking Iguana: The stack trace is precious!

The stack trace is one of the most valuable pieces of information you can have when trying to debug a problem. It tells you what line of code was being run when an error was thrown and gives you an idea of the execution path that lead to that line of code being run.

Quick plea then. Please don’t do this:

def foo

do_something

rescue => e

puts “Problem: #{e}”

raise e

end

Better Ruby Idioms « Katz Got Your Tongue?

Carl and I have been working on the plugins system over the past few days. As part of that process, we read through the Rails Plugin Guide. While reading through the guide, we noticed a number of idioms presented in the guide that are serious overkill for the task at hand.

myronmarston’s mail_safe at master - GitHub

Keep your ActionMailer emails from escaping into the wild during development

Ruby5

Heard of Redis? In this episode we cover how you can use it in your application and how GitHub uses it for Resque. Heroku Asset Packager, mail_safe, and JSBlogger are also covered, along with why you should use conditionals rather than exceptions.

Building a Twitter Filter With Sinatra, Redis, and TweetStream @ DigitalHobbit

The app I came up with is Twatcher, so go check it out to get an idea of what I’m talking about. It (admittedly very crudely) identifies funny tweets by looking for tweets that contain the word “lol”. It then renders matching tweets using a simple UI not unlike that of twitter.com itself, and visually highlights the word “lol” in each tweet for emphasis. Perhaps most importantly, the app uses AJAX to periodically (currently every 10 seconds) pull in new tweets.

Architecture

In the remainder of this post, I will describe the architecture of Twatcher, along with the rationale behind it. I will also share some code snippets that should allow you to follow along and build your own Twitter filter app.

Heroku | Tech: Sending email with Gmail

These days, it seems like almost all apps need to send email. And everyone has a gmail account. So why not have your app send email through Gmail? It’s fairly easy with just a few steps.

Git – Fixing a Defect » Engineering Blog

It’s Tuesday morning and a bug has just been found in production. We were about to start working on a user story, but we need to switch gears and fix this bug.

Rackspace Cloud Computing & Hosting |  NoSQL Ecosystem

The fundamental problem is that relational databases cannot handle many modern workloads. There are three specific problem areas: scaling out to data sets like Digg’s (3 TB for green badges) or Facebook’s (50 TB for inbox search) or eBay’s (2 PB overall), per-server performance, and rigid schema design.

The Ruby revolution is over | Merbist

Yes, Ruby made it’s revolution and the world “has changed”. But a real movement doesn’t die after its revolution, that’s actually when it has to be strong and defend its values.

This doesn’t mean that Ruby is dead or that Rails is “passé”. To the contrary, Ruby imposed itself as a new valued and respected player, a new standard if you will.

Ruby is certainly not the “new kid in the block”anymore nor the “popular kid”, however lots of older kids seem to want to have her on their team. (.NET, Java, Objective-C can all use Ruby)

What Beautiful HTML Code Looks Like | CSS-Tricks

Things Caches Do

There are different kinds of HTTP caches that are useful for different kinds of things. I want to talk about gateway caches — or, “reverse proxy caches” — and consider their effects on modern, dynamic web application design.

Hackido: Install Ruby on Rails on Ubuntu Karmic Koala 9.10

If you’re running Ubuntu 9.10 and want to install Ruby on Rails I’ve put together a quick tutorial for you. Not tremendously much has changed since the last tutorial for Jaunty Jackalope. Unicorn is out and while I think it’s nifty, I’m going to wait a little while before playing with it. For now my money is still on Phusion Passenger as being the right tool for the job. If all that seems fine, let’s get to the details.

Michael Tsai - Blog - Perl vs. Python vs. Ruby

I’m evaluating Python and Ruby as replacements for Perl. I’ve been using Perl for several years and am very comfortable with it, although I’m definitely not an expert. Perl is a powerful language, but I think it’s ugly and encourages writing bad code, so I want to get rid of it. Python and Ruby both come with Mac OS X 10.2, both have BBEdit language modules, and both promise a cleaner approach to scripting. Over the past few weeks I read the Python Tutorial and the non-reference parts of Programming Ruby, however as of this afternoon I’d not written any Python or Ruby code yet.

has_web_fallback :: Leftbrained

f you look at any HTML formatted mail-shot it’ll usually contain the legend “To view this online, click here”. The main reason for this being that most email tools suck at rendering HTML. Therefore, it makes sense to give the recipient the chance to view the message in their browser. To do this, the originating system can’t fire-and-forget email; it needs to cache a version for viewing online.

Has_web_fallback gives you transparent, easy caching of ActionMailer HTML emails.

You’re An Idiot For Not Using Heroku // RailsTips by John Nunemaker

It is true. You are. Go try it now. That is an order. I can wait for you to come back and finish reading this post. I could end the post now, but I suppose I’ll go on and tell you a bit about my experience with Heroku yesterday.

Blog post - danopia

Ruby on Sails is a project that I started about two weeks ago (10/19/2009). It is a homebrew Google Wave provider. The short history of the project has had many setbacks, including IRB dropping characters when I paste in packets, me having to write a custom Ruby ProtoBuffer parser, and a few rewrites of old code that already was old and badly designed (in a week-old project that was written from scratch!).

almost effortless » no-www Rack Middleware

I’m pleased to present my submission to the CodeRack contest: no-www.

This middleware catches requests that begin with “www” and redirects them to the more reasonable “non-www” address.

Benchmarking Ruby exception handling - Ruby

Which is better, handling an exception or explicitly checking to see whether or not your code is going to break? The answer is “it depends”. On the one hand exception handling allows us to write more legible code (often summed up by the saying “it’s easier to ask forgiveness than permission”). On the other, handling an exception is often a costly operation; it can be faster to “look before you leap”.

But just how costly is exception handling? Happily it’s very easy to find out. I was working away with my pair recently when this very question came up. We were calculating a ratio between two numbers, but wanted to modify the calculation so that if the denominator was 0, we’d use 0.5 instead.

rake start

I’m working on a Sinatra app that uses MongoDB. I’d love to start both Sinatra and MongoDB at the same time, then kill them at the same time, too. Luckily we can use Rake’s multitask for this.

Git – Working on a User Story » Engineering Blog

We recently started using Git as our version control system at Rally. Switching to Git has been a learning experience for many of us. I would like to share our experiences using Git in a team environment.

YUI Theater — Ron Adams: “Automated Integration Testing with YUI Test, Selenium and Hudson” » Yahoo! User Interface Blog (YUIBlog)

Ron Adams is a Yahoo! engineer in Southern California who has worked on a variety of Yahoo!’s media products including OMG and who now works for Yahoo! Sports. Ron has been working with colleagues in QA to automate the exercise of JavaScript unit tests, and his YUICONF 2009 session was entitled “Automated Integration Testing with YUI Test, Selenium and Hudson.” As the title suggests, he outlines the process he’s developed using YUI Test for JavaScript unit tests, Hudson as a CI/build tool for tracking and monitoring results, and Selenium as the tool to exercise the JS unit tests in the browser.

Google Code Blog: Introducing Closure Tools

Millions of Google users worldwide use JavaScript-intensive applications such as Gmail, Google Docs, and Google Maps. Like developers everywhere, Googlers want great web apps to be easier to create, so we’ve built many tools to help us develop these (and many other) apps. We’re happy to announce the open sourcing of these tools, and proud to make them available to the web development community.

High Scalability - High Scalability - A Yes for a NoSQL Taxonomy

NorthScale’s Steven Yen in his highly entertaining NoSQL is a Horseless Carriage presentation has come up with a NoSQL taxonomy that thankfully focuses a little more on what NoSQL is, than what it isn’t

PaulBarry.com - How To Write A Spelling Corrector In Ruby

If you haven’t seen it before, Peter Norvig has a spelling corrector that is written in just 21 lines of Python code (not counting blank lines and the import). He also lists a few other implementations in other languages, include one in Ruby. The Ruby one was listed as 34 lines. I was surprised that it was that many lines more in Ruby, so I wanted to give it a try.

Debug-level Logging for a Single Rails Production Request : Andy Jeffries : Ruby on Rails, MySQL and jQuery Developer

We have a large Rails site live which runs with production level logging. Occasionally there is a problem where debug-level logs would help us track down a problem quickly, but we can’t restart one of the Rails servers to have logs put in debug mode for a single request (and don’t want to run in debug mode for long as the servers are heavily used).

There is also the problem that Rails log entries often get interleaved with each other, although this is a partially solved problem with a Rails log analysis tool I wrote. However, for our purposes it would be nice to have just the log output for the single request we want to look at.

The best solution is to change the log level in Rails’ console and then make a single fake request.

Brightbox Blog - Ruby on Rails Hosting – Queues and Callbacks

A major part of our work behind the scenes is about improving our internal processes and, whenever possible, automating tasks. To this end we have a number of systems that need to communicate with each other.

The Control Panel that you may be familiar with uses Delayed Job. This is a Rails-specific gem that uses the database as a queue, with a nicely packaged worker process that handles messages as they arrive. Because the Control Panel only ever talks to Rails from Rails, this worked extremely well.

However, our other systems were not homogenous – there are a number of different interfaces that needed to be instructed at various times and across various machines, and Delayed Job didn’t really fit the bill.

entp hoth blog Postmortem of Tender issues

I love these post mortems of server issues. Gives you an idea of how it is done.

Proper way to detect Windows platform in Ruby - The Empty Way

require ‘rbconfig’

WINDOZE = Config::CONFIG[‘host_os’] =~ /mswin|mingw/

Devise: Flexible Authentication for Pragmatic Rails Developers

Devise (GitHub repo) is a new Rails authentication library/engine developed by Brazilian development company Plataforma. It’s pitched as a “flexible authentication solution for Rails.” Devise builds upon Warden, a general Rack authentication middleware, while offering Rails developers a flexible but easy to use front end.

asemanfar - Bluepill: a new process monitoring tool

Over the past several weeks, two co-workers and I wrote a simple process monitoring tool: bluepill, because it keeps things up. Bluepill replaces the existing process monitoring tool we were using which we had some issues with.

Skills Matter : London Ruby User Group:Thinking functionally

During our last meeting, Tom was surprised by how many people (both Ruby newbies and “Rails not Ruby” programmers) were asking questions about Enumerable, e.g. what map/inject/zip etc do. Tom has massive functional chops and is going to give a talk that starts with this and then expands into a rant about programming in a functional style

Quick Tip: Readable Conditional Validations in Rails - Intridea Development Blog

This is something that many may already use as a best practice, but if not it’s something simple and convenient to add to your repertoire. Sometimes you may have a model that requires additional information if a certain condition is met. For example, I may require a user to add more information about themselves if they wish to be listed publicly, whereas I would not if they do not wish to be listed. By combining ActiveSupport’s Object#with_options and ActiveRecord’s conditional validations, we can implement this behavior in a straightforward and readable manner (assuming here that there is a boolean field called “listed” in the database that is exposed as a checkbox or similar to the user):

Katz Got Your Tongue?

As you might have heard, Carl and I released a new project that allows you to bundle your gems (both pure-ruby and native) with your application. Before I get into the process for using the bundler today, I’d like to go into the design goals of the project.

Rails Best Practices

Dr Nic ’s Hacking someone’s gem with github and gemcutter

Ever used a rubygem, found a bug, and just wanted to quickly bust out the big guns and fix it quickly?

The gem command doesn’t come packed with a way to find the original source repository for a gem. At best, most gems at least come bundled with the complete source, tests and documentation. Some gems don’t. Fair enough, since having access to the complete source via the gem still doesn’t allow you to fix a bug and share it with the world.

For that you access to the repo, a quick way to fork it, and a post-github way to share a gem version from yours truly.

How to pass request context to ActionMailer and supply the :host value to url_for – Simone Carletti’s Blog

The epic battle me against ActionMailer has finally come to an end and I’m quite satisfied with the final result.

Have you ever tried to generate URLs within an ActionMailer template? If you did at least once, then you are probably familiar with the following error:

ActionView::TemplateError (Missing host to link to! Please provide :host parameter or set default_url_options[:host])

This happens because ActionMailer instance doesn’t have any context about the incoming request so you’ll need to provide the :host, :controller, and :action:.

SapphireSteel :: Who Needs IronRuby?

This provides us with a dilemma. We are the only people who have a Visual Studio IDE for IronRuby. In its current form it is a pretty simple IDE but it already has the foundations upon which we could, in principle, build the full range of VS tools - debugging, IntelliSense and the rest, as we have done for our standard Ruby IDE, Ruby In Steel. But, at present, we do not know if doing so would be a good use of our time. Over the past couple of years, we have had very few requests for extended IronRuby support. Will that change when version 1.0 of IronRuby is released? Or will IronRuby find itself in that difficult position of being too-Microsofty for Ruby developers and not Microsofty enough for .NET developers?

Introducing Resque - GitHub

Resque is our Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later.

Background jobs can be any Ruby class or module that responds to perform. Your existing classes can easily be converted to background jobs or you can create new classes specifically to do work. Or, you can do both.

Dr Nic ’s First look at rails 3.0.pre

Today I had my first look at rails 3.0.pre and below are the sequence of steps I had to take to create a rails 3.0.pre application, and get it’s generators to work.

Why was I looking at the top-secret, yet open-source Rails 3.0? Their generators are being migrated over to Thor and I wanted to see them in action. I was thinking I might migrate newgem to use Thor too.

Ruby Programming Tutorials | Man With Code

Ruby Programming Tutorials

This is the outline for the Ruby Programming tutorial series. Each link is a link to the video, which has the full transcript and source code below it. Enjoy!

Limelight

Unlike many other frameworks, Limelight applications are built using only one language: Ruby. Every aspect, from the screen structure and styling, to control logic and business modeling, is written in Ruby.

WNYC - Radiolab: Sperm (November 21, 2008)
Finally somebody points out how obnoixious “Only in America” is.
2009-01-03 - Today’s Ruby/Rails Reading
2009-02-13- Today’s Ruby/Rails Reading

Tags: ,

This entry was posted on Sunday, November 15th, 2009 at 2:53 pm and is filed under Ruby on Rails. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.