Articles

Scout Improves App Monitoring for Rails Developers

scoutparts.pngBack in early 2008 I wrote about Scout on Ruby Inside, announcing it as a new "Ruby powered Web monitoring and reporting service." This is still true, except for the "new" bit!

NFi Is Looking for an Agile PM / ScrumMaster

 NFi Is Looking for an Agile PM / ScrumMaster

I’m helping one of our clients – NFi

Unicorn!

We’ve been running Unicorn for more than a month. Time to talk about it.

What is it?

Unicorn is an HTTP server for Ruby, similar to Mongrel or Thin. It uses Mongrel’s Ragel HTTP parser but has a dramatically different architecture and philosophy.

In the classic setup you have nginx sending requests to a pool of mongrels using a smart balancer or a simple round robin.

How a 1-Engineer Rails Site Scaled to 10 Million Requests Per Day

ravelry.pngRavelry is an online knitting and crochet community run by husband and wife team Casey and Jessica Forbes.

Building Shoes for Windows: to show a button correctly

There is no magic, there is only awesome (Part 3)

This is the third article in a series titled “There is no magic, there is only awesome.” The first article introduced the “four cardinal rules of awesomeness”. The second article discussed knowing your tools.

Thinking

That the makeup department did something horrible to that dog.

More MongoMapper Awesomeness

In which I dish on the latest MongoMapper features like dirty attributes, time zone support, custom data types and dynamic finders.

September was a month of craziness and for the first month in quite a while I did not post here. I promise it hurt me as much as it hurt you. In an effort to get back in the rhythm, I am going to start with an easy article. MongoMapper has been getting a lot of love lately and I thought I would mention some of the awesomeness.

Double Shot #558

I’m getting too old for these late nights.

Speed up manual testing

jquery.populate

Manual testing your web app is a pain when you have lots of forms which need to be filled in. Not anymore!

Usage


  $('input').populate();

Inputs with a name containing ‘first_name’ will be filled in with a random first name, etc.

What if I want to add a new field type?


  $.populate.registerValues({
    favoriteColor: ['red', 'green', 'blue']
  });

Now favorite_color inputs will be filled in with a random color choice from [‘red’, ‘green’, ‘blue’]

Articles | Rails Fire

Articles

New features: Extra disk space, IP addresses & Multiple email contacts

Today we pushed a couple more updates to the control panel. Now, rather than creating a ticket, you can order more disk space and additional IP addresses for any of your boxes directly from the control panel. Additional disk space can be purchased for just £5 per 10GB block and IP addresses for £2.50/month (with one-off setup of £30).

brightbox-your-brightboxes-3

finding what has been changed

Frequently you may want to easily see what has been changed as you’re working. Perhaps you just went out for a bite to eat and temporarily forgot, or maybe you need to check to see just what will be added into your newest commit. There’s a few Git commands that can help with this and make it very easy to figure out what has been modified.

What's New in Edge Rails: HTTP Digest Authentication


This feature is scheduled for: Rails v2.3

Long ago, in your mother’s version of rails, we got a http basic authentication plugin. That functionality has since been rolled into Rails core, but it was always lacking HTTP digest authentication. Until this commit, that is.

News Release: RailsConf Opens Registration and Spotlights Rails' Next Generation: Rails 3 - Merges Rails and Merb

Sebastopol, CA, January 26, 2009 - Want to see Rails 3 roll out? O’Reilly Media and Ruby Central have opened registration for RailsConf 2009, happening May 4-7, 2009, at the Las Vegas Hilton. RailsConf, the official event for the Ruby on Rails community, will showcase the latest developments in the merger of Rails and Merb into Rails 3.

exporting your repository

Previously there was a tip that covered sharing changes but that included all of your repository’s history. What if you just want to export a certain commit’s changes? Or just one folder? What if you wanted to make an archive of the repository for backup? Fear not, for Git can do all that and more. Thanks to Stack Overflow for providing with some helpful hints to add into this post.

Ruby each_cons

As methods go, each cons is pretty mysterious. I’m not even sure exactly what you would use it for. However, in the interest of science, here is a brief discussion.

UPDATE
Gregory Brown, who wrote the Prawn PDF library, suggests that:

“In general each_cons is useful when you need a sliding window of size n across a dataset.”

/update

Amazon AWS EC2 RubyOnRails Rails-All-in-one

As you may know, standard template “Amazon EC2 Rails-All-in-one-trial” by Amazon AWS is not good… yeap, it is.
Let me show you how fix it by your hads :)

Let’s start.
We have a useful EC2 based on CentOS 5.2. Great enterprise linux for the Rails application.
But Ruby 1.8.5 on aboard, it’s deeply out-of-date…

http://rubyonrails.org/download
We recommend Ruby 1.8.7 for use with Rails. Ruby 1.8.6, 1.8.5, 1.8.4 and 1.8.2 are still usable too, but version 1.8.3 is not.

Ruby Detect Enumerable (AKA Ruby Find enumerable)

I love Ruby’s enumerable methods.

Enumerable#Detect is probably one of the least well known, and thus most people never use it.

It’s the exact same thing as Enumerable#Find. It’s actually stupid simple.

Of course, it’s not as glamorous as superstars like map or select, but as I explain below, it’s a nice way to remove an additional method call.

invalid geometry format (geometry.rb:36:in `from_s') attachment fu

If you get the error:

invalid geometry format vendor/plugins/attachment_fu/lib/geometry.rb:36:in `from_s’

when running attachment fu, it means that this regex from attachment fu:

RE = /\A(\d*)(?:x(\d+))?([-]\d)?([-]\d)?([%!<>@]?)\Z/

is not getting matched.

This is likely because you are setting your image to resize to something like ‘380x’.

Setting it to 380x used to work, but no longer does, it appears.

The future of FuzzyFinder-TextMate

Back in October I released a Vim extension for mimicking TextMate’s cmd-T file lookup feature. I use it heavily now, and it works great for me.

Sadly, the author of the FuzzyFinder Vim script, upon which my extension depends, keeps changing internal implementation details that I had to hook into to make my extension work. The result? Every few weeks my extension breaks with the latest FuzzyFinder.

Articles | Rails Fire

Articles

Living without send(), or trying to

Object#send (or __send__) is a scrappy little tool we Rubyists pull out to ever-so-casually ignore method private and protected visibility, and to call methods dynamically.

Maybe we’ve gotten into the habit of using it a little too often. Let’s play with alternatives.

An evaluation

Here’s an example from practically every monkeypatching Rails plugin init.rb you’ve ever seen:

smartly save stashes

I seem to be using stashing more and more, and I’ve found that seeing the stash list output looking like this isn’t very helpful:

CabooseConf '09

Hey everyone! CabooseConf 09 is on again. For those of you who don’t know, we have been running a free anti-conference at the same time as the O’Reilly Railsconf behemoth. Last year, Chad and Gina approached me after the conference and asked if we would run it again this year, but under the banner of Railsconf itself. Keep your friends close, I guess ;)

Clarity: A reminder

If it’s not immediately obvious that your app works, it’s broken. Anything that your customers can’t figure out how to do doesn’t work.

I’ve known this for a while, but when you hang out with web developers and college students (I’m in college), it’s easy to forget.

Here is what I do now, what most people will do in 5-10 years, and what you probably do now too:

Temporarily disable ActiveRecord callbacks

ActiveRecord callbacks can be super-handy, but every once in a while, they get in the way.

How to get hired by ENTP

At ActiveReload, our question was “How good are you at Gears of War?” Will qualified with flying colors (he was 100th in the world).

xbox

Last year as ENTP was starting, it was “How good are you at Rock Band?” Towski impressed us with his killer Chris Cornell impersonation.

rocking the house

3 Simple Guidelines for Contributing

In which I describe simple guidelines for contributing to other people’s open source projects.

So what drives someone to contribute to an open source project? 95% of the contributions I have received on my various projects are from people who are trying to make one specific thing work for something they are doing.

Google Chart 4 Rails (GC4R)

Charts are generated by Google API.

Install: ruby script/plugin install http://gc4r.googlecode.com/svn/trunk/

Supported features:
1.line chart
2.bar chart (vertical and horizontal)
3.pie chart (both 2D and 3D)
4.title, title color and size
5.data colors and legend
6.data scaling
7.multiple axis

#Controller

use_google_charts

#In method of controller

Default Chart or Hello World Chart

Export to Excel in Ruby on Rails

Below code will help to export the data in excel in Ruby on Rails

#Controller

class UserController < ApplicationController
def export
headers['Content-Type'] = "application/vnd.ms-excel"
headers['Content-Disposition'] = 'attachment; filename="report.xls"'
headers['Cache-Control'] = ''
@users = User.find(:all)
end

#View

export.html.erb

Basic Ruby on Rails Cardinality and Associations

Active Record associations can be used to describe one-to-one, one-to-many and many-to-many relationships between models. Each model uses an association to describe its role in the relation. The belongs_to association is always used in the model that has the foreign key.

(1) One-to-one

Use has_one in the base and belongs_to in the associated model.

models/employee.rb
has_one :address

models/address.rb
belongs_to :employee #foreign key – employee_id
end

(2) One-to-many

Articles | Rails Fire

Articles

Rails caching – resources

When you create anything serious on Ruby on Rails, you will most definitely need to start thinking about caching. As Ruby is a high-level language, a lot of crunching goes on to make the magic work. So in order for all this magic to work you should ensure that the heavy-lifting is done only once and after that you just use the results.

Good news is that caching in RoR is very powerful standard feature.

Post-Mortem of This Morning's Outage

At 07:53 PDT this morning the site was hit with an abnormal number of SSH connections. The script that runs after an SSH connection is accepted makes an RPC call to the backend to check for the existence of the repository so that we can display a nice error message if it is not present.

Distlockrun: Lockrun for Your Cloud

Lockrun is a handy little utility for ensuring you don’t run two of the same cron job (or other task) at the same time on one machine. It’s especially handy when the cron job in question has a widely varying duration. Lockrun was written by Steve Friedl and initially released in 2006.

Thanks to the NFi Studios Team

NFi Studios

Face Brutal Facts

Companies must face the fact that consumers and employees have a loud voice, and that relationships with them can no longer be one sided.

Double Shot #573

Been a very long week, but I’m happy with the way various projects are improving.

#338 | “Ryan Bates’ nifty-generators” in Category: Useful tools for daily routine

»Synchronizing Core Data With Rails 3.0.0.pre«

Ruby – Get ASCII value

Example 1:

puts ?r  #=> 114

puts ?a #=> 97

Example 2:

output=”raveendran”

puts output[0]  #=>114 ‘value of r’

puts output[1] #=> 97  ‘value of a’

Example 3:

output=”raveendran”
output.each_byte do |a|
puts a
end

>ruby ascii_from_ruby.rb
114
97
118
101
101
110
100
114
97
110
>Exit code: 0


 

Watir – handling hidden process in windows

Code:

def running(a)

running=`tasklist`

if running.include?(a)

puts “#{a} is already running in windows machine”

else

puts “#{a} is not running”

end

end

runnning(‘java.exe’)

#=>   java.exe is already running in windows machine

runnning(‘notepad.exe’)

#=> notepad.exe is not running

Where this code will useful:

We can able to chaeck the process is runnign or not — When Script need to close some opened Firefox windows or chrome windows

Presently Adds SharePoint Integration

We’re always looking for ways to make it easier to integrate Presently into your day-to-day workflow. Today, we’re happy to announce something that will make it much easier for businesses using Microsoft’s SharePoint to integrate Presently. Starting today businesses can use the Presently SharePoint Web Part.

rails-upgrade is now an official plugin | Rails Fire

rails-upgrade is now an official plugin

I apologize for not getting another Rails 3 upgrade post up this weekend, but I spent this weekend working on a few things. First, I contributed a few little pieces to the Rails 3 release notes, which should be showing up on the Rails blog soon (edit: or view them here right now), but most of my time was devoted to a bigger project.

My little gem rails-upgrade is now rails_upgrade, an officially blessed upgrade tool that will be maintained by myself and the Rails team. You can get it from here: http://github.com/rails/rails_upgrade.

To use it now, simply install the plugin:

script/plugin install git://github.com/rails/rails_upgrade.git

The plugin adds the following tasks:

rake rails:upgrade:check      # Runs a battery of checks on your Rails 2.x app
                              # and generates a report on required upgrades for Rails 3
rake rails:upgrade:gems       # Generates a Gemfile for your Rails 3 app out of your config.gem directives
rake rails:upgrade:routes     # Create a new, upgraded route file from your current routes.rb

Simply run those tasks in the same way you ran the commands with the rails-upgrade gem. In the near future, I plan on expanding the checks for deprecated pieces to handle some of the less obvious changes, adding some generators for other changes (like config/application.rb), and adding some extra tools (ideas/suggestions certainly welcome).

Anyhow, I’m really looking forward to seeing this project become a dependable upgrade tool. If you have any ideas or find any bugs, please contact me via e-mail or Twitter or, even better, fork it and handle it yourself!