Posts Tagged ‘rubyyot’

So What’s the Deal with IndexCards?

Wednesday, March 24th, 2010

What’s all this IndexCards nonsense?

IndexCards is a website that I’ve been devoting a good deal of my free time to recently. It is a family project where we draw new stuff on index cards everyday.

So it’s an Art Project?

Well yes, and no. IndexCards is:

  • An Art Project – You got me, yes it’s in some ways completely non-technical.
  • A Family Activity – Since my kids have gotten involved, it has just gotten better and better.
  • An Evolving Sinatra Based Website – My first Sinatra based project, and I am really liking it.
  • A Way for Me to Try out Tokyo Cabinet – I’ve found that I don’t always need a relational database.
  • An Opportunity to Use my Razsell Gem – A live app that consumes feeds from Zazzle.
  • A Design Project – Let’s face it creating a website from scratch that is part of the design community raises the bar a little.

IndexCards is an Art Project

I created IndexCards in response to the Design Something Every Day Challenge posted on Smashing Magazine at the end of 2009. I enjoy drawing and painting, but have directed so much of my interest towards Ruby and Open Source Projects (and the internet) in the past couple years that I haven’t spent time creating any art. As a new years resolution, I decided to change this by accepting the challenge.

IndexCards is a Family Activity

After a month or so of me scribbling away on little pieces of paper, my kids asked me what I was up to. So I explained that it is a project to help me to improve my artistic skills and “enjoy the journey” so to speak. They all wanted to participate and so I’ve been including them since then. Recently, I’ve started creating Art Night events where I introduce a theme and we all start drawing away. It has been a great family activity and I’ve been very impressed by all of their work.

IndexCards is an Evolving Sinatra Based Website

OK there is a technical side to this project, but that’s perfect for me. I find that I like both the technical and creative sides of things. When one side of my brain needs a break I can flip over to the other and continue working on the project. A lot of the site’s inner workings are not visible from the web, but there is definitely a web based component. For that I decided to use Sinatra and it’s been great to work with. It’s a lot more open that working with Ruby on Rails, but many of the tedious parts of working directly with Rack have been smoothed out. I’m interested
in creating another Sinatra based application.

IndexCards is a Way for Me to Try Out Tokyo Cabinet

Another technical bit I wanted to try out in Tokyo Cabinet a key value store of Mixi fame. I used the rufus-tokyo gem to interface with Ruby along with the Repository pattern. I was really worried at first that I’d get to a point where I really
needed a relational database and I’d have to rewrite the data persistence in MySql. As the project goes on, I’m finding that my fears were unfounded. Tokyo Cabinet was a great fit for the project.

IndexCards is an Opportunity to Use my Razsell Gem

Ah Razsell. I created this gem while starting out on Kung Fu Tees, a T-shirt design site I wanted to make with my kids. Kung Fu Tees, this far is vaporware, but Razsell has emerged as it’s own project any users. It allows you to query the Zazzle.com rss API and consume the feed to populate a store. Using it has caused me to make a few changes, which is great, because that’s what happens when you really use the code you write.

IndexCards is a Design Project

So I’ve always been wary of CSS and web design in general. I mean I’m ok at it, but am generally disappointed with the look of my sites when I compare them to so many of the other websites out there. Designing a website that is part of the web design community ups the ante a bit. So far I’m not
completely satisfied with it, but it is much better than I’d feared it would be.

But, Why Index Cards?

I wanted to draw daily, but I didn’t want to burden myself with a huge canvas. Index cards are the perfect size to constrain the scope of the image and challenge me to make it fit. Not to mention they are cheap and you can find them almost anywhere. That leaves a little budget for art supplies, and
I’ve been picking up a few things here and there. Just today I ordered a Lamy Safari fountain pen to try out, and am looking forward to it.

Original small works of art (OSWOA) have
stemmed from the Artist Trading Cards and ACEO communities on ebay. Maybe I can find a tie-in for those. They fit right in.

IndexCards is fun, You Should Check it Out

If you haven’t been to IndexCards go take a look. Maybe you will be inspired to do some art of your own.

Moving soon

Monday, February 1st, 2010

I got frustrated with Dreamhost the other day because they downgraded the version of git available on the server to v1.4.4.4. That broke what I’d done with rubyyot.com. So I got a virtual server on Linode. It’s very nice so far. Hang on things will be in transition for a little while.

Building rubyyot.com from scratch with Rack and Git

Sunday, January 10th, 2010

2010 is here, where did the time go?

Huh? It’s 2010? I haven’t posted in 6 months? What happened?

Summer of Learning Challenge

The Summer of Learning Challenge didn’t happen. I didn’t even do it. No excuses. I did other things.

All is not lost

Around the end of 2009, I dusted off my idea of creating a git based wiki like publishing portal with Rack. I put it together in about a week or so and it’s slowly evolving and gaining some content. It’s fun, even exciting, to bypass frameworks and DSLs and all the opinionated code and build something on the leanness that is Rack. A great learning opportunity to boot. So maybe something came of the challenge after all.

Rubyyot – Rack + Git

It’s up on rubyyot.com with the source on github still wonderfully rough around the edges and in need of a code review. Ahh, to create something again.

Flannel – Warm and fuzzy

I made my own markup parser for this, it’s called flannel and an liking it so far. Of course it too is still in it’s infancy, but I’m not only using it to format my wiki thing, I’ve also given it a little command line attention to allow it to transform text files for my blog posts. It’s warm, fuzzy and everything is just as I want it, and if not, I change it.

Plans for Rubyyot.com and the Summer of Learning Challenge

Sunday, May 24th, 2009

Plans for the future

In the past week I started playing with Rack and put together a little Rack application that generates content from my blog’s rss feed about the site.   As I stated in that post I really didn’t like having the “parked” page up there, and I also wanted to try out Rack, which has gotten so much press of late.   I was very impressed with Rack, and how easy it was to put together a simple web application with it.

Until that point, I had used Rails, used non-Ruby web frameworks and used Ruby for other non web-based projects, but I had not created a Ruby based web application with anything other than Rails.  It was an enlightening experience.   It got me thinking about Rails, what it provides out of the box:

  • ActiveRecord for persistent, vendor agnostic storage and model building goodness
  • Built in support for AJAX and partial views.
  • Controllers to coordinate between them
  • Simple support for REST web services
  • ActionMailer for email handling
  • Flexible url routing
  • An active and growing community that provides a large number of useful and often cutting edge add-ons and guides.

Additionally, many of these features are modular and can be swapped out or replaced with other modules to suit your tastes.  That is quite an impressive and list, and by no means comprehensive.  With Rails 3 on the horizon, there are even more great things on the way.   It’s no wonder, that I fell in love with Rails.

However, I realized that a number of things I use to develop Rails applications are not truly Rails features, but only supported by Rails.  This by no means a slight against Rails, but it is something great about Ruby and the Ruby community.   Here are some features and libraries that I make use of:

  • erb – Templating engine available in ruby itself.
  • rake – An essential make utility for automating reoccurring tasks.
  • Test::Unit – Unit testing framework, baked into Ruby.
  • Cucumber, RSpec and friends – There are group of great libraries available for testing Rails and other Ruby apps.
  • git and github – Fast, distributed source control and repository hosting.
  • Rack – The new hotness in standardized web server interfaces.
  • Capistrano – Automated deployment.
  • Phusion Passenger – Once called mod_rails, it is actually more than that, as it supports all Rack based applications.
  • Dedication to best practices and self-improvement – While not technically a feature, it is ingrained in the Ruby and Rails communities and it’s contagious.

Chances are, if you have done any Rails development you have encountered, used and enjoyed some or all of these.   My point here is not to say that Rails is only great because Ruby is great.  Rather that while Rails is awesome, there is a strong and viable codebase for building applications, web-based or otherwise, in the greater Ruby community.  The relationship between Rails and Ruby and the popularity of Rails as a framework have made both better and stronger tools.

Building Cohesive Applications

This relationship would not be as be strong, if Rails was built as  a monolith.  Instead, Rails is designed in to be modular.  The framework itself is broken up into no less than 6 gems:

rubyyot@atlas:~$ jruby -S gem install rails
Successfully installed activesupport-2.3.2
Successfully installed activerecord-2.3.2
Successfully installed actionpack-2.3.2
Successfully installed actionmailer-2.3.2
Successfully installed activeresource-2.3.2
Successfully installed rails-2.3.2
6 gems installed

Within that, as we saw, the standard way of building rails uses a number of other tools and libraries.  These parts are generally built to be highly cohesive rather than highly coupled.  This property of good design is probably best described by Uncle Bob’s SOLID principles.  These are:

While these principles were written with less dynamic languages than Ruby in mind, such as Java and C#.  Understanding them and applying them  in any language will help you to write clean code.  Code with minimal dependencies that strangle it’s agility and make make maintenance a nightmare.  These SOLID principles also make code more modular and enable the long promised re-usability that all object-oriented programmers learn about in OO101.

Ruby Web Frameworks

One of the trends in the Ruby and Rails communities in the past year or two, has been the building of other web frameworks.  These were often termed micro-frameworks because they offered the ability to build ruby based web applications without having to run a full Rails stack.  The most notable of these are Merb and Sinatra.  While these began to splinter ruby based web development, my mantra for this year is:

Change is good.

These project went and approached the building of web applications in Ruby in different ways.  In doing so they opened up the doors to creativity and brought some improvements and  fresh ideas to the table.  The benefits of this are even now coming clear with the announcement that Merb will be merged into Rails 3.  This promises to bring more speed and modularity to the Rails framework.

Pragmatic Thinking and Learning

I recently completed the book Pragmatic Thinking and Learning.  It was an excellent book that centers around bringing our innate creativity (R-mode) to the party to achieve goals and solve problems.  While it’s a book targeted to technical people it is not written for one specific language or even just for programmers.  It takes a number of interesting studies and theories, most notable for me is Betty Edwards’ Drawing on the Right Side of the Brain and brings them together into a series of tips and hueristics for improving your thought processes.  It’s a very interesting book and I would recommend it to anyone interested in the topic.

Rails and Lettuce

In of the book, Andy Hunt is discussing personal wikis and shows a page from his WikiNotes (figure 8.3 ).  It shows a series of thoughts as follows:

  • U.S. per capita consumption of Romaine lettuce increased 162%
  • Lettuce consumption at a record High
  • Convenience of pre-washed, bagged lettuce outweighs cost.
  • MORAL: it’s got to be easy

I thought that this was a particularly interesting observation and in a way is a metaphor for Rails.

The sales of Romaine lettuce increased 162% by pre-washing and packaging it in convenient bags.   This packaging is widely popular in spite of the increased cost.  It’s clear that lettuce is a great product.  Everyone knows it’s healthy and it’s the building block of salads and great in sandwiches as well.  Still it’s popularity were greatly improved by giving it an instant, right out of the box, interface.   Similarly Ruby web frameworks are great products.  Rails packages that goodness up in an easy to learn, build and deploy.

Reinventing the Wheel vs. Digging a Rut

Rails is built on top of Rack.  Rack is written in Ruby and specifies the interface between the web server and the Rails framework.  In fact Merb and Sinatra are built on top of Rack as well.  Still, as we saw, Rack is available for building upon directly and of course Ruby and it’s libraries are available as well.  So why not build a Ruby web application without any framework at all?  Well the obvious answer is that you won’t have all of the nice things that these web frameworks provide.  Not to mention many of these pieces have now been used and tested by production applications for years now.  It may be a better question to ask:

Why wouldn’t I want to use one of the pre-built frameworks?

The answer to that question is what has been forming in my mind since I tried out Rack for the first time.

  • Frameworks remove options - Even the best framework on the planet is going to take away options.  Lean Methodologies include the idea of delaying decisions as long as possible allowing for greater flexability later on.  Many times we want to use a framework, because it leave a clear path to a production ready application.  This comes at the cost of options and I don’t want these removed.
  • Learning Opportunity -  Often the best way to learn something is to do it.  I’m not an expert with Rails, I still have more to learn, but I also want to learn more about writing and designing applications for the web in general.  Therefore it makes sense to bypass the framework and hook directly into Rack.
  • Many libraries are still available – As we saw before, many of the tools used in the creation of Rails applications are still available for use.
  • Completely Custom – I used to love watching shows like American Chopper and Monster Garage even though I know next to nothing about building a car or a bike.  The thrill was in watching highly skilled people create baddass and functional custom vehicles.  This is a similar though admittedly geekier endeavor.
  • Beginner’s Mind – This zen concept urges you to remove look at things without filtering them through your pre-conceived ideas and biases to gain greater understanding.  Approaching this project without relying on a pre-conceived framework should lead to similar results.

All of these are great reasons for me to try making my own path and not generating yet another Rails application.  That’s not to say that Rails isn’t great, or I’m better than Rails.  It’s just not the right fit, right now for my project.  In the end I’d rather re-invent the wheel than dig myself into a rut.

Vaporware and Playing to Learn

One thing that I do when working with my personal projects is that I will have an idea and start to run with it.  After a while of working with the idea, more ideas will come and my attention will turn away from my original project and move on to other things.  Some examples of this are:

  • Resolvr – A dependency injection mechanism for Ruby.
  • Gippr – A library for parsing the GIFT file format.
  • RSimpy – A wrapper for the API to Simpy.com

Will I ever get back to these and complete them?  Maybe.  Much of what I do in my personal projects is playing to learn.  Like when I was a kid and I wanted to build a giant working  robot or transformer out of legos.  Did I ever finish these projects?  No, but they were fun and I learned a number of interesting things along the way.  This is one of the great things about personal projects.  There is no one expecting you to deliver a product, so you are free to persue whatever interests you.  Even if that means that you abandon the project altogether and move on to another.

There is a character on the show Jimmy Neutron, that my kids watch,  called Professor Calamitous. He is a brilliant scientist bent on doing evil.  However, he is continually undone by his character flaw, that is that he can never finish anything.  I have often teased my wife, because she will get very excited about a project and work on it.  She won’t just do a little, but she really digs into it and attacks the subject.  After some time she will, almost overnight, lose interest and move on to something else.  I’ll tell her that her inner Professor Calamitous has struck.  In actuality, I’m just as guilty of it as she is if not more so (sorry for teasing you).

When viewed from a goals oriented perspective this is a horrible waste of time.  Why put all the energy into something that will be left to rot, unfinished?  From another perspective, that of a learning tool, it is a great accomplishment and a goal achieved.  The time wasn’t wasted because in doing something with the project, rather than just reading (or writing, speaking, etc.) about the topic, you develop hands on experience and engage much more of your mind (R-mode) than you would have otherwise.

Personal Wiki

Now I feel it’s my duty to bring all of these random thoughts together and issue a challenge to any out there who might be reading this.   The book, Pragmatic Thinking and Learning, recommends the use of a personal wiki to gather together your thoughts and organize them into an exocortex.  I looked through all of the available wiki software out there and none of them really felt right.  That was a kind of personal decision and it’s nothing against any of the software available.  They either didn’t provide the features I wanted, or I didn’t like the look and feel.

Requirements

  • Good feel – If I’m going to do this, I will be spending a significant amount of time with it.  Any tool I will be spending that much time with, better not have annoyances, no matter how small.
  • High Availability – While it may not need to be as available as a ubiquitous collection tool, it should be available to me at work and at home, at the very least.
  • Wiki Formatting - Whether via wiki markup, RedCloth or some other means it should be easy to build and grow as a wiki.  That’s kinda the point of a Personal Wiki
  • Single user editing -  It may seem odd to have a wiki that is editable by a single person, but if it’s just for me, then it only makes sense.
  • Public display – Some of the things I put in it would make sense to be available to others who are interested.
  • Private display – Some of the things in it may be private and kept that way.
  • Easy backup and recovery – If I’m going to go to all the trouble of writing and gardening a wiki, it should be safe and recoverable in the event of corruption, disaster or my own foolishness.
  • Customizable – I may want to have dynamic content on some pages.  Perhaps it should pull in my bookmarks on a topic and display them with other content.

That is quite a hefty list and I’m sure that there will be other things along the way that I’ll want to put in there.  It’s no wonder I couldn’t find what I wanted out of the box.

I’ve decided to build this directly on Rack, using git, github and other useful tools I would use in building a Rails app.  I’m not sure how this will go at this point, but it’s an exciting project and I hope to have something to show for it by the end of summer.

The Summer of Learning Challenge

We all have these kinds of ideas floating around in our heads, and the more creative ideas we listen to and act upon, the more will come to us.   I think that right now is a great time, as it is the beginning of Summer 2009 to act on one, or more, of these.  The summer provides a set time frame that is long enough to make something great, but short enough that we won’t put it off forever.  I think that it would be great to see others (you) find a project they are interested in a make a commitment to work on it this summer.  If you are a developer/programmer, make your project open-source.  It could be a great benefit to others.  It will defiantly be a great experience for you.

A few years ago I took part in and completed NaNoWriMo.  My book wasn’t finished at the end, but I wrote 50,000 words of it in one month.  That was a great accomplishment for me, something that I didn’t think I could do when I started.  By setting the goal and working toward it I was able to complete it.  It felt great.  What could you do if you set your mind to it?

What Will You Do?

If you are interested in taking the challenge or just have an idea or a comment about mine.  Please leave feedback or blog about it yourself an leave a postback.  It’s going to be a great summer.  Enjoy!

Using Rack to generate content from an rss feed

Tuesday, May 19th, 2009

The Hype

Rack is taking the Ruby and Rails worlds by storm. It’s hard to find any recent Ruby related posts that don’t mention Rack in some way or other. It’s obvious that Rack is here. If you haven’t read up on it. Jason Siefer has put together a good post full of links to get you started.

The Project

I recently killed Rubyyot.com, the GTD task management site. It turns out that using computers to take notes just isn’t convenient. I haven’t quite figured out what is, but I suspect that it involves pencil and paper. In any case, I decided to take the site down since I wasn’t using it. The site had a pretty “this domain is parked” page on it, which I wasn’t particularly fond of.

So to make the site more interesting, I wanted to be able to display an news items that I might have available about the domain. However, I already have a blog, this one here. I didn’t want to write a full rails app to post blog entries, or have yet another wordpress site. What I wanted to be able to do was post to my blog and if the item had to do with the rubyyot domain have it show up in the page I have there as well.

What I needed was a way to take an rss feed from my blog for the tag rubyyot and post the items to a page on Rubyyot.com. That is exactly what I did in a few hours with some help from Rack.

The Host

Rubyyot.com is hosted on Dreamhost which supports Passenger. And here is one of the nice things about Rack. Rack is a standard interface and so Passenger supports Rack. All Passenger needs to run a Rack app is a rackup file (config.ru) a public directory for css, images and other files available to the public. Finally, it needs a file to trigger a Passenger restart, this is located at tmp/restart.txt.

It turns out that since Rails now runs on Rack, you can simply configure your app in the Dreamhost Webpanel as you would a Rails app. Instead on putting the Rails app at this location, you simply put the Rack app there. In my case I put a git repository there, though I may try to capify it in the future.

The Experience

All in all, it was a painless experience. The code needs a little cleanup but it works. Dreamhost had Rack and Hpricot already installed on the server, not the current versions of the gems, but this didn’t cause an issue. I wanted to put it out here to show how easy it can be. In the future, I would like to use a similar technique to be able to post status or news messages to any of my sites from my blog.

The Code

Note: The full code can be found on github tagged as first_post

#config.ru
require 'rack'
require 'rubyyot_status'
 
run RubyyotStatus.new

and

#rubyyot_status.rb
class RubyyotStatus
  def call(env)
    require 'rubygems'
    require 'hpricot'
    require 'open-uri'
 
    # Setup beginning of page and initial status value
    text = "<h2>Rubyyot.com is going through changes</h2>"
    text << "<p>If you are looking for my blog you can find it <a href='http://blog.rubyyot.com'>here</a><p>"
    text << "<h3>Latest Updates</h3><ul>"
 
    css = '<link rel="stylesheet" type="text/css" href="/rubyyot.css" />'
    response_body = "<html><head><title>Rubyyot</title></head>#{css}<body>#{text}"
    status = "200"
 
    begin
      # read rss feed
      doc = Hpricot.XML(open("http://blog.rubyyot.com/tag/rubyyot/feed/rss"))
 
      (doc/"item").each do |item|
	# get link, description and title from feed
	link = (item/"link").inner_html
	description = (item/"description").inner_html
	title = (item/"title").inner_html
 
	# add each post to page
	response_body << "<li><h4><a href='#{link}'>#{title}<a></h4>#{description}</li>"
      end
    rescue
      status = "500"
    end
 
    # finish off page
    response_body << "</ul></body></html>"
 
    # add headers
    headers = {}
    headers["Content-Length"] = response_body.length.to_s
    headers["Content-Type"] = "text/html"
 
    # return values
    [status, headers, response_body]
  end
end

See it in action

Working version (at least for now) is at Rubyyot.com.