A Natural Language Date/Time Parser for Ruby: chronic

Posted by Daniel Butler Sun, 10 Sep 2006 23:00:00 GMT

Chronic is a natural language date/time parser written in pure Ruby.

require 'chronic'

Time.now #=> Sun Aug 27 23:18:25 PDT 2006

#---

Chronic.parse('tomorrow') #=> Mon Aug 28 12:00:00 PDT 2006

Chronic.parse('monday', :context => :past) #=> Mon Aug 21 12:00:00 PDT 2006

Chronic.parse('this tuesday 5:00') #=> Tue Aug 29 17:00:00 PDT 2006

Chronic.parse('this tuesday 5:00', :ambiguoustimerange => :none) #=> Tue Aug 29 05:00:00 PDT 2006

Chronic.parse('may 27th', :now => Time.local(2000, 1, 1)) #=> Sat May 27 12:00:00 PDT 2000

Chronic.parse('may 27th', :guess => false) #=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007

Chronic uses Ruby’s built in Time class for all time storage and computation. Because of this, only times that the Time class can handle will be properly parsed. Parsing for times outside of this range will simply return nil. Support for a wider range of times is planned for a future release.

Time zones other than the local one are not currently supported. Support for other time zones is planned for a future release.

Cronic @ Rubyforge

Posted in  | 2 comments

Ruby on Rails Plugin: CriteriaQuery

Posted by Daniel Butler Thu, 07 Sep 2006 01:00:00 GMT

You'll like this code:

Person.query.namelike('name').join('address').citylike('city')

... and CriteriaQuery brings it to you (via Max Muermann) as a Ruby on Rails plugin. Head to the README for some useful examples, like this awkward beauty:

pq = Person.query pq.disjunction.firstnameeq(params[:name]).lastnameeq(params[:name]) if params[:name] pq.category_id_eq(params[:category]) if params[:category] ... address = pq.join("address") address.state_eq(params[:address[:state]]) if params[:address[:state]] ... end

Neat, huh?

CriteriaQuery Plugin Documentation Page
Ruby Plugins Directory Entry

Posted in  | no comments

Prototype Carousel Class for Ruby on Rails

Posted by Daniel Butler Wed, 06 Sep 2006 23:32:00 GMT

Sébastien Gruhier of Carquefou, France, a new Rails convert (after 13 years of C++/Java) has provided a handy Prototype/Scriptaculous Carousel component, which does not use any Yahoo User Interface JavaScript components. A carousel component allows you to view a window into a image stream, with forward and reverse buttons that allow you to navigate through the images.

Yahoo's page describes the component:

The carousel component manages a list of content (HTML UL and LI elements) that can be displayed horizontally or vertically. The content can be scrolled back and forth with or without animation. The content can reference static HTML content or the list items can be created dynamically on-the-fly (with or without Ajax).

The current version supports both static and Ajax content.

Prototype Carousel Component Home Page
Original Carousel Component Documentation

Posted in ,  | 1 comment

The New Ruby-Lang.org

Posted by Daniel Butler Wed, 30 Aug 2006 22:00:00 GMT

A new design for ruby-lang.org is coming, and it's very Web 2.0. Sweet.

Ruby Lang Logo

_why's Blog Article
New Site
Old Site

Posted in ,  | no comments

Rails No-Nos Now

Posted by Daniel Butler Wed, 30 Aug 2006 21:45:00 GMT

Kevin Clark of San Diego has posted an article describing several deprecated features of Rails--thing you should fix now or they'll break later. Quickly, they are:

  • Accessing Instance Variables You Didn’t Create
  • Stop using find_all and find_first
  • Don't write the AJAX-enabled feature before you write the simple fallback feature.
  • Stop asking for things not directly related to your problem.
  • Don't use scaffolding.
  • Don't use components.
  • Don't use engines unless you're going to do it right.
  • Use layouts more
  • Don't use Rails Paginator class
  • Don't put controllers into namespaces.

I don't completely agree with all of Kevin's findings, but you should at least view the article to be aware of some of the problems that you might encounter using these less than best practices features.

Things You Shouldn't Be Doing in Rails

Posted in  | no comments

Beware of "Assumed Logged In" Attacks

Posted by Daniel Butler Wed, 30 Aug 2006 11:01:00 GMT

Brian Ellin of Portland, Oregon, warns us of "assumed logged in" attacks, which are cross-site attacks in which another site carefully crafts a URL that opens in a hidden frame which performs a destructive action on a different site that you are assumed to have been logged in to. His solution: the secure-action-plugin. He describes the problem and the solution:

In an assumed logged in attack, a malicious site assumes the visitor is logged into your site. The malicious site manually crafts a URL to a destructive action on your site (change email, delete account, etc.) and opens the URL to that action in a hidden iframe. The browser then sends the user’s cookies and actions may be performed on your user’s behalf without them ever knowing. This technique may be used to steal accounts, inject or delete account data, or perform other malicious actions.

The plugin works by overriding ActionController.url_for and adding a signature of the user’s session_id and some salt to URL query strings. By adding a sig that includes the user’s session_id, it makes it impossible to for malicious sites to create URLs that will work on your site for anyone but themselves. The signature is verified before a secure action is executed.

Until now, I had not conceived of this type of attack. Thanks, Brian.

Secure Action on the Rails Wiki Page
Plugin Home Page
Ruby Plugins Directory Entry

Posted in  | no comments

Modal Information Boxes: RedBoxPlugin for Ruby on Rails

Posted by Daniel Butler Tue, 29 Aug 2006 14:22:00 GMT

Craig Ambrose, an Aussie from Melbourne, has announced the RedBox Plugin for Ruby on Rails. He writes,

I've written a little plugin to use for displaying a block of html over a page while fading out the background. This is like the lightbox.js library, and all it's related offshoots (thickbox, greybox, etc.). My plugin, Redbox, is not really any better than these others (in fact, it's less mature, and less tested), but it builds on prototype and scriptaculous, is available as a rails plugin, provides easy to use helpers, and unlike the other libraries, works very well with rails' ajax functionality.

Looks nice, and it's easy to use. Thanks, Craigh.

Craig's Blog Entry
Demo Page
Ruby Plugins Directory Entry

Posted in  | 1 comment

Older posts: 1 2 3 4 5 ... 11