Amazon.com Widgets
...not so private reflections of greg.newman
Categories & Search

Recently in Ruby on Rails Category

The Pug Automatic: Flickr Style Tagging in Rails

Someone asked on IRC for Ruby code to split tags Flickr style, e.g. getting the tags from tag1 tag2 'tag 3 has spaces' tag4.

I came up with this:

def parse_tags(string)
  string.split(/"(.+?)"|\s+/).reject {|s| s.empty? }
end
It even preserves tag order, which you wouldn't get if you'd first gsub out (and store) quoted tags and then split the rest."

I haven't tried it yet but looking at it looks like a fine implementation. Very simple.

[Via Pug Automatic.]

The MissingDrawer plugin for TextMate has been resurrected, enhanced and released. The plugin "provides Xcode-like project window interface without drawer."

missingdrawer.jpg

Changes since Hetima's version (2006-11-08)

  • slightly larger line height of file list
  • visual tweaks of file list frame
  • new resizer handle (as in Mail.app)
  • new resize method
  • smaller project buttons
  • saves the position of the pane splitter automatically
  • Show/Hide Project Drawer (⌃⌥⌘D) menu item shows/hides the panel

I've been using it for the majority of the day and it's a welcome change to the already excellent TextMate.

A fantastic prototype script for Mac dictionary lookups.


var selection;
if(window.getSelection)
  selection = window.getSelection();
else if(document.selection)
  selection = document.selection.createRange();

document.observe('dblclick', function() {
  if(navigator.userAgent.include('Macintosh')) {
      location.href = 'dict://' + selection;
    }
});

A quick (and probably dirty) Prototype-based hack allowing Mac users to get the definition of any word by double clicking it.

[Via AlternateIdea - Home.]

Tumblr developer Marco Arment opened up Instapaper, his latest side project. Think of it as a inbox for pages you want to pass up and read later. Instapaper gives you a bookmarklet to save the pages for retrieval when you have time to catch up.

Marco describes it as:
* You come across substantial news or blog articles that you want to read, but don’t have time at the moment.
* You need something to read while sitting on a bus, waiting in a line, or bored in front of a computer.

Instapaper

I think the thing I like most is the signup process. Put in your email address and you're done. If you want a password, add one and you're protected. Otherwise, there's nothing else to do but fill it up with pages to read later.

Starling is a light-weight persistent queue server that speaks the MemCache protocol. It was built to drive Twitter's backend, and is in production across Twitter's cluster.

Ezra Zygmuntowicz has posted A Quick Jaunt Through Merb's Framework Code, a tutorial on some of what's going on under the hood. I'm intrigued by this framework but since there's not much documentation yet I haven't really jumped into it full force.

(Via I am rice.)

I installed it on Safari 3.0.4 (Leopard) and it works great. You can find out more about Microformats at Microformats.org, and while you're at it, check out Mofo, a rails plugin to work microformats into your project.

Get your merb on!

Nov 7, 2007

Merb 0.4.0 was released last night along with a new site merbivore.com.
The nice thing about this release is it's now ORM agnostic for those of you working with CouchDb. In fact alot of merb is agnostic which makes for a fast and powerful MVC framework.

Merb-thumb.png

You can read more about the changes on the merbivore website or Ezra's narrative of the changes.

Check it out!

EJS via MinusMor

Feb 17, 2007

In a recent project I had to come up with a way to include a partial based on a condition from a dropdown selection. Conditionals in RJS? I don't think so. So thank you Dan Webb for your kick-ass MinusMor plugin. What this does is allow you to embed ruby in javascript as an .ejs extension which gets evaluated before any rjs templates.

So with an observe_field I do:

<%= observe_field 'field_to_evaluate', :url => {:action => 'my_ejs_template_name' } %>

I create an ejs template and insert the following code.

if (document.getElementById('field_to_evaluate').value == "my_true_value") { $('div_container_to_update').update(<%= partial('the_partial_to_show') %>); }

Now the field it is observing is a dropdown menu. Whenever the selection is true, I see my partial.
Again, a big thanks to Dan Webb!

Dan Benjamin has written updated instructions on how to install Rails, Mongrel and Capistrano on your Mac. As always with Dan, his instructions are very to the point so you won't have to search around for alternate methods.