Rails Reading February 14 2010

The Bull of the Bullring

The case for embedding jruby-complete into your application | Atomic Spin

Why in the world would you want to embed JRuby into your application instead of relying on a regular Ruby or JRuby installation? I can think of three reasons.

Developing Sites With AJAX: Design Challenges and Common Issues - Smashing Magazine

What Is AJAX?

After the main HTML document has loaded, AJAX loads content from the server and replaces parts of the document with that content rather than reload the main document. It’s as simple as that. AJAX stands for “Asynchronous JavaScript and XML” and was meant to load only XML documents, but we soon used it to load everything under the sun, and so the XML part was quickly forgotten. The asynchronous part is the killer feature; but what is it?

DailyJS: Park your Horse, Code Cowboy: Professional JavaScript Workflows, Part 1

When it comes to professional practices, is your JavaScript always stuck with the short end of the stick?

Take this simple quiz to find out. Do you…

* Break up and organize your code into small, easily digestible files?

* Keep only one canonical copy of third-party libraries?

* Use a deployment workflow, to concatenate and minify automatically?

* Automatically generate documentation?

* Unit test your business logic?

Pivot.new - Redefine a method from a module like a Gentleman

I was recently presented the problem of appending to the initialize method from a module that was being included. To do this it would need to override the class’s initialize method with my own but keep the functionality of the original initialize method.

Whenever I need to do something in Ruby that I know will require some experimentation I like to move outside of my application and reproduce the problem in a simple way. For this problem I created a Person class that mixes in a Teacher module.

WebFinger libraries emerge - The Changelog - Open Source moves fast. Keep up.

Less than 24 hours after Google broke the news on WebFinger, its 21st century take on the Unix finger command, enterprising developers are releasing native libraries for the service.

In case you missed it, WebFinger is a way to get profile information for a user of a service based solely on their email address.

aruba - Cucumber steps for testing your command line apps - The Changelog - Open Source moves fast. Keep up.

Terminal junkies rejoice! Now you can use Cucumber to test your command line interfaces just like you do for your web apps. Aruba from Cucumber creator Aslak Hellesøy provides familiar step definitions for testing output, exit statuses, and file system commands.

Unit Testing Sphinx | Pathfinder Development | Software Developers | Blogs

Sphinx (and its rails plugin thinking-sphinx) is my choice of search engine on ruby/rails project. It is powerful yet super easy to setup.

However, testing Sphinx code is not easy at first. Since Sphinx works by leverging database commit hooks, it cannot be tested within the bounds of unit testing framework that rails provides. This is understandable because, in rails testing, a transaction is started before each test that is bound to rollback after the test is finished. Since the test data is never committed, sphinx doesn’t get a chance to index anything and cannot be tested.

Riding Rails: Plugin Authors: Toward a Better Future

Some of the biggest changes in Rails 3 involve how Rails expects plugins to behave.

<3! — Testing your dependencies with RSpec

I’m finding that managing my projects’ code dependencies is smelling worse and worse as time goes on. Code bases get bigger and acquire libraries as they grow; a part of your project sits untouched for a few months and its particulars leave your medium-term memory, and so on.

In Rails, we can freeze lots of stuff to our vendor directories. I do that as much as possible—gems that I only use for Rails apps get frozen to vendor/gems and then uninstalled system-wide; I use the gemsonrails plugin for this. If the little gem bits aren’t necessary, you can just pistonize a repository. Old news.

That’s not going to fly for platform-compiled gems, or even compiled libraries that aren’t gems at all (since you’re possibly running several different platforms between development and production). So I’ve been cooking up ways to keep myself sane:

PaulBarry.com - Node.js Presentation

Barking Iguana: Keeping the software on your Ubuntu server up-to-date

There are two things that you as a server operator need to know how to do to stay up-to-date with the software on your server and make sure that it’s always supported. One is upgrading installed packages, and one is upgrading to the next release of Ubuntu. I’ll cover them both one at a time, but first we’ll do a little setup to make sure that both operations are nice and fast.

Monitoring Delayed Job with Bluepill and Capistrano | Plataforma Tecnologia Blog

So, you already did the right choice of using Delayed Job for your background processing, great! But, how are you going to be certain that your background processing will still be happening while you are sleeping? And if your Delayed Job process goes down, are you going to wake up in the dawn e restart it manually? I wouldn’t do that, I really appreciate my sleep. So, what’s the solution?

As rubyists and railers, we already know there are solutions, like God, that do this job for us. However, there are another solutions, like Bluepill. Bluepill is a process monitoring tool like God, but, unlike God, it doesn’t have memory leak, according to its authors.

MetaSkills.net Synchronizing Core Data With Rails (3.0.0.pre)

This is my presentation to our local @757rb/@757objc users group this past Tuesday. Hope some find it useful.

Lessons learned from building HomeMarks native iPhone application to synchronize Core Data with a RESTful backend built using rails 3.0.0.pre. This covers a previous design methodology called the AJAX head pattern which decouples rails applications from the views they present which allowed an easy API foundation for the iPhone application and data sync methods.

Quick and easy static pages in Rails | Ruby On Rails Blog

Sometimes you have a Rails app, the core functionality is not a CMS, and you need to add some static pages to your app that don’t get changed often, eg, an about us page, privacy policy, etc.

This post shows you a quick and easy way to do that in about 60 seconds, without using a database model or having to write any sort of CMS.

Ruby Metaprogramming Course – Start Thinking in Ruby

After the huge success of the first two “Ruby Metaprogramming” batches, RubyLearning now announces the third official batch from 6th Mar. 2010.

litany against fear ¤ by nick quaranto ¤ The Rails Module (in Rails 3)

So, you may have noticed this in the Rails 3 Changelog…

Railties now deprecates:

RAILS_ROOT in favour of Rails.root,

RAILS_ENV in favour of Rails.env, and

RAILS_DEFAULT_LOGGER in favour of Rails.logger.

Great…but why? Better alternatives have existed for a while in Rails core (some since 2.1.0), and it’s about damn time you start using them properly. There’s also some other helpful methods on the Rails module we’ll explore in this post.

Getting Up To Speed With Rails 3

I’m proud to announce that darwinweb.net is now running Rails 3.0-pre. I undertook the project as part of Bugmash last weekend, but it turned out to be a very deep rabbit hole; a two-day bugmash was too short to really dig into the meat of Rails 3 which is in ample supply.

The scope of changes to Rails is astonishing. There’s a lot of new blood contributing and brilliant ideas are popping left and right. The result is that Rails 3 represents a major maturation inflection point. It’s graduating from the scrappy, opinionated upstart to a very modular and full-featured framework containing what may once have been considered a disturbing amount of enterprise-readiness. It’s bittersweet and perhaps a bit ironic that the internals have acquired so many moving parts, but as a professional Rails developer the new flexibility and modularity is far too awesome to denounce in any way.

How to upgrade plugins to Rails 3.0 / Boldr

Rails 3.0 beta is out and it’s now time to upgrade all the plugins available. To show you how to do it I’ve decided to create a small plugin compatible with Rails 2.x and Rails 3.0. It’s a wrapper around Rack::Cache to insert it automatically in a Rails application.

Bulletproof backups for MySQL | Carsonified

has_many :bugs, :through => :rails: Signed and Permanent cookies in Rails 3

David added a very cool feature to Rails recently – Signed cookies and permanent cookies This lets you set permanent and/or signed cookies very easily.

prefuse | interactive information visualization toolkit

The Building Blocks of Ruby « Katz Got Your Tongue?

Let’s cut to the chase and use a better example of the utility of Ruby blocks.

omgbloglol - The Path to Rails 3: Greenfielding new apps with the Rails 3 beta

PythonLearn - Self-paced learning Python

**Note that the book doesn’t yet have any chapters relating to informatics at this point.

ryanb’s importex at master - GitHub

This Ruby gem helps import an Excel document into a database or some other format. Just create a class defining the columns and pass in a path to an “xls” file. It will automatically format the columns into specified Ruby objects and raise errors on bad data.

This is extracted from an internal set of administration scripts used for importing products into an e-commerce application. Rather than going through a web interface or directly into an SQL database, it is easiest to fill out an Excel spreadsheet with a row for each product, and filter that through a Ruby script.

Rails Plugins

Rails3 compatible plugins so far

Rails 3.0 Beta: 36 Links and Resources To Get You Going

Whenever something’s a really “big deal” in the Ruby world, we cover it - even if it makes more sense on Rails Inside (which is now switching to a user contributions model). Given that, we’ve gone through all the latest and greatest Rails 3.0 related links and put together a ton of them to help you on your way with the recently released Rails 3.0 beta. Enjoy!

Railscasts - Rails 3 Beta and RVM

Get started with Rails 3.0 Beta and install Ruby 1.9.1 using RVM: Ruby Version Manager. Stay tuned to the end for a challenge on giving back to open source.

The making of the NYT’s Netflix graphic – The Society for News Design

One of The Times’ recent graphics, “A Peek Into Netflix Queues,” ended up being one of our more popular graphics of the past few months. (A good roundup of what people wrote is here). Since then, there have been a few questions about the how the graphic was made and Tyson Evans, a friend and colleague, thought it might interest SND members. (I bother Tyson with questions about CSS and Ruby pretty regularly, so I owe him a few favors.)

DealNews: Scaling for Traffic Spikes | Scalable web architectures

Last year Dealnews.com unexpectedly got listed dealnews.comon the front page of yahoo.com for a couple of hours. No matter how optimistic one is, unexpected events like these can take down a regular website with almost no effort at all. What is your plan if you get slashdotted ? Are you ok with a short outage ? What is the acceptable level of service for your website anyway.

One way to handle such unexpected traffic is having multiple layers of cache. Database query cache is one, generating and caching dynamic content is another way (may be using a cronjob). Tools like memcached, varnish, squid can all help to reduce the load on application servers.

lindsaar.net A Different View…

Bundler rocks, but you need to think differently about how to start and run your Rails app.

Rails 3 Blog Club - Week 1 on Vimeo

Hashrocket discussing rails3 blog posts

Rails 3 Beta is Out — A Retrospective | Engine Yard Blog

The Rails team has finally released the Rails 3 beta, after more than a year since the Rails and Merb teams started working on this release. You can read all about it at the official Rails blog, but I figured I’d take the opportunity to share my take on the release.

BBC - Web Developer

Coding considerately means doing your absolute best to make sure your styles don’t mess about with parts of the page that you have no business messing about with. Let’s start with includes.

SafeBuffers and Rails 3.0 « Katz Got Your Tongue?

As you may have read, Rails adds XSS protection by default in Rails 3. This means that you no longer have to manually escape user input with the h helper, because Rails will automatically escape it for you.

However, it’s not as simple as all that.

Bundler 0.9: Heading Toward 1.0 « Katz Got Your Tongue?

As we approach the release of Bundler 1.0, which we hope to ship along with Rails 3.0 final, we took the opportunity to take a look at all the feedback people have sent so far.

Having done so, we’re proud to announce Bundler 0.9 with radically improved workflows that fit our needs and the needs of those who have contributed feedback and patches.

Live Coding Rails 3 Upgrade | Free PeepCode Blog

For several months people have wondered, “Where can I download a video that features a developer stumbling through an upgrade of a Rails 2 app to Rails 3?”

I’m proud to say that an answer is now available!

In only 25 minutes, I convert my news screenshot site from Rails 2.x to Rails 3 (prerelease, from source).

Running a Ruby application with jruby-complete | Atomic Spin

Check out this other post for a discussion of my reasons for locking down your JRuby runtime. In summary, embedding jruby-complete gives you complete control of your Ruby runtime. That’s a good thing. The downside is that discovering and executing commands through jruby-complete can be a pain. The rest of this post describes how to ameliorate the pain.

Setting up virtualization on Ubuntu with KVM - redemption in a blog

With KVM gaining official support from Ubuntu as the virtualization solution, I ended up ditching Xen and switching to KVM for these new servers on Karmic. The rest of the entry is a step-by-step guide on setting up KVM VMs on a Ubuntu server; I’m putting this down because like all wikis, the Ubuntu KVM wiki has grown a little too organically to be useful.

SD Ruby - Episode 077: Building Your Own Hosting Environment

Nic Benders will show you what’s needed for building a hosting environment for production applications. The focus will be on selecting server hardware, picking a Linux Distro, and getting your Rails app running.

Sass 2.4 will now be Sass 3.0 : Nex3

Because of this surge of energy, the goals for the next version of Sass have shifted dramatically. When we released version 2.2, we were expecting the biggest addition to version 2.4 to be some output-optimization features. Now those have been pushed to a later release in favor of much more major improvements. I’ve talked about some of these improvements already, such as a much more powerful way of dealing with colors and auto-compilation of CSS files. And there are even bigger, more exciting ones in the works.

Since we’re making such huge changes – ones that will in some ways reshape the face of Sass - a minor change from 2.2 to 2.4 feels inadequate. Thus, the next release of Sass will be version 3.0.

Railscasts - Mobile Devices

Change the look and behavior of a Rails app on mobile devices. Also use jQTouch to build a native-looking interface.

Introducing GMoney – A RubyGem for Interacting with the Google Finance API » Justin Spradlin

The Google Finance API allows users to interact with Google Finance and can help developers programmatically “request a list of a user’s portfolios, retrieve performance and return statistics on an existing portfolio, query the positions and transactions in a portfolio, and create new portfolios and transactions.”

GMoney is a wrapper for this API and allows developers to take advantage of the API’s functionality using the Ruby programming language. To minimize the learning curve I tried to give GMoney an interface similar to that of ActiveRecord so that developers would have a familiar starting point.

Commit 2ebea1c02d10e0fea26bd98d297a8f4d41dc1aff to rails’s rails - GitHub

Classic commit

Emphasized Insanity - Find all online users with Authlogic

Assuming you want to find all the users that are currently online when you use Authlogic, you might find it’s a little tricky at first since you can’t really access the sessions table from UserSession.

Depending on your SessionStore configuration, you can theoretically access the storage directly (the Sessions table, or memcached for example), but assuming you don’t want to add some unnecessary code or models to your app, you can simply use one of Authlogic’s Magic columns.

Return false with prudence - Code in the hole - David Winterbottom

One irritating programming idiom — especially common to PHP programmers — is to use a return value of FALSE to indicate that something has gone wrong, or that no valid return value could be found. Unless the only other possible return value is TRUE, this is almost always wrong.

Why your Javascript apps need more structure @ Bamboo Blog

There are several aspects to building javascript UIs, and you need to do a bit of planning beforehand if you want them to be successful. 2010 is set to be the year of Javascript’s ascendancy, and you can’t ignore it. You also need to start using it properly (if you aren’t already). We have evolved beyond the level of chucking event handlers inline in views and it is not possible to just hope for the best as things get more complicated.

Dissecting the web with Ruby and Hpricot | blog.mostof.it

Let me introduce you to an old friend of mine: Hpricot

Hpricot has saved my life many times when I had to parse (x)html documents and extract information programatically. It features a very nice ruby-ish syntax and a blazingly fast xpath-based parser. Combine it with open-uri, and you’re in for a fun ride creating a data-extracting web spider.

Ruby Best Practices - Weekend Reading: RBP Chapter 1

If you’re reading this blog, you probably know that the Ruby Best Practices book exists. Even if you haven’t read it, you might have a sense for the sort of topics we cover based on the content you’ve seen on this blog. But now, everyone is going to get a chance to read RBP the way its meant to be read: as a conversation.

For the next 8 weeks, I will post a chapter from RBP every Friday. You don’t need to pay me a cent if you download it, but what I do want you to do is leave a comment here sharing your thoughts once you’ve finished reading. This way, we can use RBP’s content as a jumping off point for conversation, rather than treating it like some sort of static rulebook. Through this process, we can discover what our common practices really are. Over time, I will incorporate these ideas back into the manuscript, helping to keep the book up to date and relevant.

Testing terminology | Atomic Spin

The terms I prefer (and generally what Atomic developers use as well, though I’m sure we have some internal variation) are useful in the context of an agile development process. They’re also meaningful in more traditional testing cultures, though it’s quite likely that dedicated testers or “QA engineers” are performing the testing.

I have a simple taxonomy for the sorts of tests that developers create: unit, integration, and system. My friend and former colleague Paul Jorgensen taught this to me years ago and it’s worked quite well.

lindsaar.net A Different View…

Action Mailer has long been the black sheep of the Rails family. Somehow, through many arguments, you get it doing exactly what you want. But it takes work! Well, we just fixed that.

Action Mailer now has a new API.

From Zero to Rails3 on Windows in 600 seconds

From Zero to Rails3 on Windows in 600 seconds

StackOverflow cool Ruby questions 3 - Khaled alHabache’s official blog

Welcome to the third post of this series. Just before diving into the new questions’ set, I want to mention a little script that I wrote to notify the user when a new question is posted on Stackoverflow, it works on Mac and uses growl.

Now let’s proceed to questions:

Two practical examples of Rack middleware in Rails | Floorplanner Tech Blog

After Rails moved to Rack as server interface, the ability the use Rack middleware was one of the most touted advantages. At first, it wasn’t very clear to me why this was such a big deal. However, I have applied Rack middleware in the last month on several occasions. I thought it might be interesting for other Rails developers to see some practical examples of middleware, to see where they can be applied.

it’s barley a task manager « processi

Barley is a [for fun] task manager. It takes its name from the barely repeatable processes, of course, it can’t compare with the excellent Thingamy work processor.

Barley is a Sinatra web application wrapping a ruote workflow engine. Ruote can run many process instances issued from different process definitions, but barley’s processes are all instantiated from a single process definition.

duncanbeevers’ dweebd » Subdomains in development using ghost

Using subdomains with Rails is kind of a pain. The only official support for subdomains is as asset hosts, as described in the AssetTagHelper documentation.

Matthew Hollingworth’s subdomain_routes covers most of the gaps in dealing with subdomains in Rails, including; generating subdomain routes, scoping resources to subdomains, and exposing subdomain information to controllers.

What I want to talk about is how I deal with subdomains in a development-environment context.

Conversational and short URLs on Rails | Carsonified

A recent project of mine got me thinking a step further than these friendly links. I wanted the URL to be conversational. Not just English, something more like an English sentence.

Iteration Shouldn’t Spin Your Wheels! | Engine Yard Blog

Ruby is a rich language that believes there should be more than one way to express yourself—the many ways of counting and iterating are no exception.

Ruby wrapper for the Delicious v2 API using the OAuth gem

I couldn’t find any examples of anyone doing this using Ruby, so I decided to have a go using the OAuth gem. It was a bit of a painful process due to a lack of decent documentation, but I got there in the end. I thought I’d share the code in case it saves anyone else a bit of time.

danwebb.net - Put that data-* attribute away, son…You might hurt someone

However, back then I explained why there is no good reason to add unsemantic configuration data into your HTML and now that we have standards-approved carte-blanche to do this I’d like to reiterate that it’s still not the way forward. If you’ve not read that article then its worth a quick read before you go on.

By all means, use data-* attributes to add semantically valuable data to your HTML but if you are just using it to prop up a script you are writing think again.

The U.S. Supreme Court has a Sarah Palin moment.
Interesting post on how flickr deals with character encoding in photo metadata
2009-02-08- Today’s Ruby/Rails Reading
2009-01-03 - Today’s Ruby/Rails Reading

This entry was posted on Sunday, February 14th, 2010 at 7:37 pm and is filed under Uncategorized. 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.