Ben Hughes

Ruby on Rails Developer, Economics Nerd, Travel Junkie...

Personal Projects

In some of my free time I've been working on some personal projects of interest. I manage my code using GitHub.


Jazztoolbox_1_m

Jazz Toolbox

Object Model for Representing Jazz Concepts - Rails

Code on GitHub

Jazz Toolbox is an online Jazz utility driven by a full object-relational and REST model of concepts in Jazz theory, establishing relationships between chords and scales, and much more. The web interface (coming soon!) is a fully Ajaxified Web 2.0 interface towards exploring these relationships and answering questions about the jazz science. The REST interface exposes the underlying data model and relationships to other developers wishing to use Jazz Toolbox as a source for their own web applications.

The core of Jazz Toolbox is a full Ruby object model representing concepts of Jazz theory, distilled to their most basic concepts and architected in a very abstract manner. The system is data-centric and all "rules" (for example, the tones in a C7 chord) in theory are self-contained in the database.

All chord/scale/mode/etc. definitions are stored as a mathematical system (sequences of numbers) which are then used to perform calculations. For example, putting some chord in a different key is a matter of adding a semitone delta and doing modulo 12.


Message_block_1_m

Message Block

More Flexible Replacement for error_messages_for - Rails Plugin

Code on GitHub

Implements the common view pattern by which a list of messages are shown at the top, often a combination of flash messages and ActiveRecord validation issues on one or more models. This allows for a nice, stylized block of messages at the top of the page with icons indicating what type of message it is (error, confirmation, warning, etc.)

This view helper acts as a replacement for error_messages_for by taking error messages from your models and combing them with flash messages (multiple types such as error, confirm, etc.) and outputting them to your view. This plugin comes with an example stylesheet and images.


Has_draft_1_m

Has Draft

Draft Sister Model Support for ActiveRecord - Rails Plugin

Code on GitHub

Allows for multiple "drafts" of a model which can be useful when developing: 1) A Draft/Live Version of Pages, for example; or 2) A workflow system whereby a live copy may need to be active while a draft copy is awaiting approval.

The semantics of this as well as most of the inspiration comes from version_fu, an excellent plugin for a similar purpose of maintaining several "versions" of a model.

This was built to be able to be tacked on to existing models, so the data schema doesn’t need to change at all for the model this is applied to. As such, drafts are actually stored in a nearly-identical table and there is a has_one relationship to this. This separation allows the base model to really be treated just as before without having to apply conditions in queries to make sure you are really getting the "live" (non-draft) copy: Page.all will still only return the non-draft pages. This separate table is backed by a model created on the fly as a constant on the original model class. For example if a Page has_draft, a Page::Draft class will exist as the model for the page_drafts table.


Has_meta_data_1_m

Has Meta Data

Rails Plugin

Code on GitHub

This plugin allows you to extend one of your models with additional supplementary data stored in another table through a has_one relationship. The benefit of this plugin over a simple has_one is that the meta model class is dynamically defined (though extendable via the has_meta_data declaration) and fields on the meta model are automatically delegated to from the main model, allowing you to work solely with your primary model and not worry about the storage of the data in a separate meta table. This plugin also automatically handles creation of the meta model if you set a field on your model that exists in the meta model table.

Common use cases for this are database efficiency if only a small number of your records have a certain set of data or in conjunction with STI to accomplish something akin to Class Table Inheritance (CTI).

In short, it’s a transparent way of splitting up data into two tables while still treating them as one model.


Goplay_1_m

GoPlay!

An Ajax-heavy multi-player Go game built with Merb, DataMapper, and jQuery

Code on GitHub

This application was built for a class at RIT, "Web Client-Server Programming". I decided to use this as an opportunity learn Merb and DataMapper and build an ajax-heavy multi-player game that understands (at a basic level) the rules of the Go board game. In developing this, I concentrated mostly on building a solid object model that elegantly represents concepts in the game. I also developed quite a bit of JavaScript for this, including a "remote event listener" that polls for and handles events from the server via Ajax and hands them off to observing functions.

"Go Play! allows you to engage in multiple games at once. On your dashboard several game invites may come in and be listed in your game invites list. Accept a game invite, and the Go game opens in a new window, allowing you to play separate games with different people in separate windows."

"Go Play has a thorough understanding of the way Go works from a programmatic perspective, with data structures and algorithms derived from GnuGo, a powerful Go AI engine. While Go Play! does not currently support any AI functions, it's format-decoupled REST interface allows for all sorts of programmatic functionality. "

"Go Play! was written using some of the most powerful and dynamic tools in modern web application development and is architected using strong object-oriented concepts and solid software engineering principles such as low coupling and high on abstractions. "