Tag Archives: ruby

The Chronic: A Ruby Time Library

So, I was trying to use Ruby to get the date 6 months ago.  This is usually accomplished using the core extensions in ActiveSupport, which is OK, but it was too much work.  Then, I found an awesome article talking about Chronic, a minimal date/time parsing library for Ruby:

$ irb -rrubygems -rchronic
irb(main):001:0> Chronic.parse('6 months ago')
=> 2010-03-25 21:10:10 -0400

Wow that’s like so awesome.  I wonder what else it can do…

irb(main):002:0> Chronic.parse('three days after memorial day')
=> 2010-09-28 23:00:00 -0400

Well, that didn’t work.  Maybe I’ll submit a patch…  How about this?:

irb(main):014:0> Chronic.parse('three days after today')
=> 2010-09-28 23:00:00 -0400
irb(main):015:0> Chronic.parse('three days after tomorrow')
=> 2010-09-29 12:00:00 -0400

Well, that worked.  Patch time!


Well, I added US non-religious holidays to chronic.  It took me a while to figure it out, but it works!

irb(main):001:0> Chronic.parse("MLK Day")
=> 2011-01-17 12:00:00 -0500
irb(main):002:0> Chronic.parse("christmas eve")
=> 2010-12-24 12:00:00 -0500
irb(main):005:0> Chronic.parse("christmas")
=> 2010-12-25 12:00:00 -0500

Of course, my original example still fails, because Memorial Day is very special:

# (last Monday of May, traditionally 30 May)
text.gsub!(/\bMemorial Day\b/i, 'last monday in may')

The last selector still doesn’t work since it’s not an identifiable ordinal.  If someone wants to fix this, please do it.  Once things like “the last monday in may” work in all of Chronic, Memorial day will start working automatically.

You can get the ruby gem using the instructions here:


The git repository is here if you want to fork:


Quick Markaby note about conditional attributes

Say you want to set an option tag to selected only under certain conditions without the code getting really ugly. Do this!:
[gist id=”552731″]
I was messing around with the ternary operator in other ways inside the element, but none of them actually interpreted properly. I hope this helps someone else struggling with this issue…

Ruby to generate RSS feeds for sites that don’t offer them

There’s this site that has an equipment exchange I wanted to keep track of. Yet, it’s done with what seems to be a custom php file rather than vbulletin, so none of the usual RSS feeds from the site apply to it. So, I decided to make a scraper/feed-generator to get me the latest version every 5 minutes and generate a nice RSS feed, so I can view it in Google Reader. The volume of posting is low enough that this won’t be annoying to see in my daily feeds.

I usually use Ruby for this because it offers Hpricot, a very nice and fast scraper and XPath interface. This time, I resolved to find something that does RSS generation better, and I stumbled upon RubyRSS, which happens to be in the core ruby distribution!
Continue reading

OSCON Sessions, Day 1

I went to 5 sessions today, and I was pleasantly surprised by most of them.


CouchDB is a distributed non-relational database written in Erlang. It is unique in that its main query interface is simply HTTP REST, and for every UPDATE, it simply creates a new version of the row. Additionally, you can request the entire history of a row very simply.


An open-source implementation of Google’s bigtable. Hypertable uses novel methods such as Bloom filters to significantly decrease query times, as well as smart messaging to distribute a database across many nodes. It is also non-relational.

Creating and supporting Free Software in Africa

A group of CS professors hailing from Africa have gotten together to create a community that fosters creativity and innovation from people in Africa. People in first-world countries can participate by acting as mentors, or directly contribute to the projects involved. Chisimba is an open-source MVC framework for rapid application development. I am very interested in contributing to this project.


I thought going in that this would be somehow in the same ballpark as Hypertable and CouchDB, but I was disappointed. Basically, they are using compression and some fairly neat indexing to speed up traditional database queries. The main problem is that they only have a Java API, which completely turned me off after 30 minutes. Before that, it seemed like they were getting some pretty promising results. If they add some more APIs in the future, this may be another one to take a look at.

A History of Failure

An awesome talk by Paul Fenwick from Australia, generally detailing failures in computer science and engineering going back into the 20th century and even back to Roman times. This was a wonderful presentation – he’s a really good speaker – and it poked a lot of fun at New Zealand.

All in all, I must say that this OSCON is much better than last year’s at least according to what I was looking for in the sessions. The exhibit hall is also very good this year – I’m pretty loaded down with swag at the moment.

I know someone who would have gotten a kick out of Temporally Quaquaversal Virtual Nanomachine Programming In Multiple Topologically Connected Quantum-Relativistic Parallel Timespaces…Made Easy! had they been here. He needs to come next year (you know who you are..)

Tonight, I also attended FOSCON 4: Cooking with Ruby. This was a spectacular event hosted by Cubespace. I have to say that the live coding competition was a great spectacle, and held everyone’s attention for hours. It was an epic battle between Symfony, Rails, Smalltalk/Seaside, and Drupal. The rankings ended up being the following:

  1. Rails
  2. Drupal
  3. Symfony
  4. Smalltalk/Seaside

The presentations were good as well for the most part (notes here). AND THEY HAD BEER! I had some of the best keg beer imaginable – I thought it would be crap like you usually get out of a keg, but this was real quality Northwestern hopped pale ale. My cup says Bridgeport Ales, so I’ll have to investigate. If anyone knows the exact beer that was available in the left-side keg tonight, I’d appreciate a comment. I also met some cool people, some of which are all into XMPP and ejabberd. I may have to check all of that out now…

Pradipta’s Rolodex Epic Conclusion

If you don’t already know about Pradipta’s Rolodex, read up here

Here’s the epic apology email from THE MAN HIMSELF!:

Hi All,

First of all I just wanted to say I apologize for the emails I sent. As of today I promise to stop the Email marketing campaigns. And I do believe it was a very…very..stupid mistake, this is the result of working late.

Also, I am deeply amazed of how talented you guys are. I mean seriously all this happened in less than 24 hours. I hope this mishap would create a benefit for all of us.

I understand this is fun for a lot of you, however, people are getting angry so if we could keep everything under the google groups that would be most appreciated.


If anyone wants to contact me feel free to contact this new email

Humbly Sorry,
Pradipta (Max) Archiputra

P.S: this time I used BCC. :)