36 Hours In...

Posted over 6 years back at Alloy Code - Home

I'm in Ur Rails...

Well, I’m long overdue for a Rumble update, the past 24 hours have been a whirlwind of activity over at team Redkey. Our application now supports team collaboration, ActionMailer backed email, and some really cool routing stuff that enables us to use the concept of users without the overhead of making those users log in.

Also, don’t forget to check out our Flickr photos. We were fortunate enough to have a guest photographer stop by the morning to take our official team photo, capturing us at our most-rested state in the past day and a half.

mms2r 1.1.8 Released

Posted over 6 years back at Mike Mondragon

mms2r version 1.1.8 has been released!

  • <http://mms2r.rubyforge.org/>

DESCRIPTION:

MMS2R is a library that decodes the parts of an MMS message to disk while
stripping out advertising injected by the cellphone carriers. MMS messages are
multipart email and the carriers often inject branding into these messages. Use
MMS2R if you want to get at the real user generated content from a MMS without
having to deal with the cruft from the carriers.

If MMS2R is not aware of a particular carrier no extra processing is done
to the MMS other than decoding and consolidating its media.

Contact the author to add additional carriers to be processed by the
library. Suggestions and patches appreciated and welcomed!

Corpus of carriers currently processed by MMS2R:

  • AT&T => mms.att.net
  • AT&T/Cingular => mmode.com
  • Cingular => mms.mycingular.com
  • Cingular => cingularme.com
  • Dobson/Cellular One => mms.dobson.net
  • Helio => mms.myhelio.com
  • Nextel => messaging.nextel.com
  • Orange (Poland) => mmsemail.orange.pl
  • Orange (France) => orange.fr
  • Sprint => pm.sprint.com
  • Sprint => messaging.sprintpcs.com
  • T-Mobile => tmomail.net
  • Verizon => vzwpix.com
  • Verizon => vtext.com

Changes:

1.1.8 / 2007-09-08 (James Grishnack – Head of Behemoth Productions, producer
of Blood Ocean)

  • Added support for Orange of France, Orange orange.fr (Julian Biard)
  • purge in the process block removed, purge must be called explicitly
    after processing to clean up extracted temporary media files.

mms2r 1.1.8 Released

Posted over 6 years back at Mike Mondragon

mms2r version 1.1.8 has been released!

  • <http: mms2r.rubyforge.org=""/>

DESCRIPTION:

MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the cellphone carriers. MMS messages are multipart email and the carriers often inject branding into these messages. Use MMS2R if you want to get at the real user generated content from a MMS without having to deal with the cruft from the carriers.

If MMS2R is not aware of a particular carrier no extra processing is done to the MMS other than decoding and consolidating its media.

Contact the author to add additional carriers to be processed by the library. Suggestions and patches appreciated and welcomed!

Corpus of carriers currently processed by MMS2R:

  • AT&T => mms.att.net
  • AT&T/Cingular => mmode.com
  • Cingular => mms.mycingular.com
  • Cingular => cingularme.com
  • Dobson/Cellular One => mms.dobson.net
  • Helio => mms.myhelio.com
  • Nextel => messaging.nextel.com
  • Orange (Poland) => mmsemail.orange.pl
  • Orange (France) => orange.fr
  • Sprint => pm.sprint.com
  • Sprint => messaging.sprintpcs.com
  • T-Mobile => tmomail.net
  • Verizon => vzwpix.com
  • Verizon => vtext.com

Changes:

1.1.8 / 2007-09-08 (James Grishnack – Head of Behemoth Productions, producer of Blood Ocean)

  • Added support for Orange of France, Orange orange.fr (Julian Biard)
  • purge in the process block removed, purge must be called explicitly after processing to clean up extracted temporary media files.

Test Coverage Matters

Posted over 6 years back at Alloy Code - Home

100 Percent Test Coverage

Inspired by City Cliq’s RSpec screenshot, we wanted to brag on our 100% RCov coverage as well. We’ve been using Test::Unit as opposed to RSpec, along with a healthy dose of Mocha to mock out external services.

For example, our application provides a convenient, tiny url to access user content, which is generated as part of a create action, generated with the ShortURL gem. In our functional test, we mock out the “shorten” method of ShortURL, and have it feed us back consistent data:

def test_create
  WWW::ShortURL.expects(:shorten).returns("http://tinyurl.com/fake")
  assert_difference "Document.count", 1 do
    post :create, :document => @@document_default_values
    assert_equal "http://tinyurl.com/fake", assigns(:document).shorturl
  end
end

Since the generated URL could potentially be different each time the test is run, I’ve removed the dependency on an external library and service to gain repeatability in my tests. I’ll take for granted that the ShortURL gem works and has it’s own tests; there’s no reason for me to duplicate their efforts. The above test simply assumes the ShortURL library is performing as expected, and allowing me to test my own code atomically.

14 Hours of Rumbling

Posted over 6 years back at Alloy Code - Home

Keith laying out our elements

Well, we’re just past the 14 hour mark since the Rails Rumble opened, and we’re making great progress. Keith Medlin and I have resurrected the “Red Key” brand to bring our revolutionary vision to life: Doxtrackr, a web-based document revision system.

The bulk of my time so far has been spent setting up our deployment environment, having done this recently for Alloy Code and Your Garage Online, I was able to speed through most of it. We’re using Mongrel, Capistrano and Nginx on Ubuntu 7.04 (breaking from the Debian herd) and have our stack already in place. We won’t be struggling to deploy at the last minute!

Keith has been focusing on our design and interface while I’ve been putting the models in place to support the site. We’ve snapped a few photos for posterity.

Keep watching for previews of our design and code process!

14 Hours of Rumbling

Posted over 6 years back at Alloy Code - Home

Keith laying out our elements

Well, we’re just past the 14 hour mark since the Rails Rumble opened, and we’re making great progress. Keith Medlin and I have resurrected the “Red Key” brand to bring our revolutionary vision to life: Doxtrackr, a web-based document revision system.

The bulk of my time so far has been spent setting up our deployment environment, having done this recently for Alloy Code and Your Garage Online, I was able to speed through most of it. We’re using Mongrel, Capistrano and Nginx on Ubuntu 7.04 (breaking from the Debian herd) and have our stack already in place. We won’t be struggling to deploy at the last minute!

Keith has been focusing on our design and interface while I’ve been putting the models in place to support the site. We’ve snapped a few photos for posterity.

Keep watching for previews of our design and code process!

Test Coverage Matters

Posted over 6 years back at Alloy Code - Home

100 Percent Test Coverage

Inspired by City Cliq’s RSpec screenshot, we wanted to brag on our 100% RCov coverage as well. We’ve been using Test::Unit as opposed to RSpec, along with a healthy dose of Mocha to mock out external services.

For example, our application provides a convenient, tiny url to access user content, which is generated as part of a create action, generated with the ShortURL gem. In our functional test, we mock out the “shorten” method of ShortURL, and have it feed us back consistent data:

def test_create
  WWW::ShortURL.expects(:shorten).returns("http://tinyurl.com/fake")
  assert_difference "Document.count", 1 do
    post :create, :document => @@document_default_values
    assert_equal "http://tinyurl.com/fake", assigns(:document).shorturl
  end
end

Since the generated URL could potentially be different each time the test is run, I’ve removed the dependency on an external library and service to gain repeatability in my tests. I’ll take for granted that the ShortURL gem works and has it’s own tests; there’s no reason for me to duplicate their efforts. The above test simply assumes the ShortURL library is performing as expected, and allowing me to test my own code atomically.

Can You Feel The Rumble?

Posted over 6 years back at zerosum dirt(nap) - Home

So the Rails Rumble is on! We’ve worked pretty hard to hook this up and it’s great to see it alive and breathing, and #railsrumble buzzing with activity. There were some capacity issues at first (ouch!) but things seem to be going pretty smoothly now.

Greets to Carter Parks, Rodrigo Kochenburger, and Erin & Tommy Shine, who all poured a lot of precious blood into this beastie. And our friends Chris Aker and Tom Asaro at Linode. And our other sponsors too, of course. Oh, and best of luck to all the Rumblers. Launch some cool-ass web properties and win some swag, guys! Hope you’ve got plenty of Red Bull to keep you caffeinated.

Me? I’m going to bed. See you tomorrow in IRC.

RubyConf 2007

Posted over 6 years back at Alloy Code - Home

The RubyConf preliminary agenda has been posted, and it looks like a really outstanding lineup!

Even better (for me, at least), is the fact that I’ve already been privileged enough to see some of these talks at the Ruby Hoedown, so I don’t feel quite as bad about having to pick and choose which afternoon sessions I’d like to attend. For those who weren’t lucky enough to make it to the Hoedown, I’d especially recommend Jay Phillips’ talk on Adhearsion. Not only were we all on the edge of our collective seat listening to him, he spent the remainder of the Hoedown with a cloud of people constantly hovering around him, peppering him with questions and was gracious enough to make sure he answered everything we could throw at him.

I’d say the feature I’m most excited about, though, is “Room 3.” I think that offering a more freeform ‘workshop’ environment is a great idea, and I’m going to have to watch my time carefully, because I can definitely see myself accidentally missing sessions I’d like to attend due to spending too long in Room 3.

Online Registration is now open, $250 per person (since the site wasn’t exactly clear on the price unless you click around a bit).

RubyConf 2007

Posted over 6 years back at Alloy Code - Home

The RubyConf preliminary agenda has been posted, and it looks like a really outstanding lineup!

Even better (for me, at least), is the fact that I’ve already been privileged enough to see some of these talks at the Ruby Hoedown, so I don’t feel quite as bad about having to pick and choose which afternoon sessions I’d like to attend. For those who weren’t lucky enough to make it to the Hoedown, I’d especially recommend Jay Phillips’ talk on Adhearsion. Not only were we all on the edge of our collective seat listening to him, he spent the remainder of the Hoedown with a cloud of people constantly hovering around him, peppering him with questions and was gracious enough to make sure he answered everything we could throw at him.

I’d say the feature I’m most excited about, though, is “Room 3.” I think that offering a more freeform ‘workshop’ environment is a great idea, and I’m going to have to watch my time carefully, because I can definitely see myself accidentally missing sessions I’d like to attend due to spending too long in Room 3.

Online Registration is now open, $250 per person (since the site wasn’t exactly clear on the price unless you click around a bit).

Introducing Addressable

Posted over 6 years back at Sporkmonger

So, after 3 months, I’m back from my excursion to Africa. Don’t worry, I’m not coming back empty-handed.

I thought my fellow rubyists might benefit from the URI implementation I’ve been using in various projects, so I’ve extracted it out into its own library. In the process, I improved a few things here and there, added support for URI Templates, and fleshed out the specifications a bit more.

I introduce to you the Addressable library.

It has about a 2:1 spec to code ratio, 100.0% code coverage, and it has gone through plenty of code heckling. It ought to be pretty reliable.

Hope you like it. Let me know how it works.

Update:

I’ve added URI Template variable extraction and I updated the documentation. The extract_mapping method should be useful for template-based routing systems for frameworks.

ActiveRecord - all vs all relationships

Posted over 6 years back at Saaien Tist

Modeling genetics or genomics data presents its own challenges. One of the issues is that the actual definition of things change over time. A database system can only be based on the scientific knowledge at the time of conception. The prime example of course is the definition of a gene over the years. Before 1997, it was believed that the vast majority of these encoded proteins. As a result, 'genes' tables in databases typically had columns to store information on the start and stop codon. However, it became clear that many genes actually do not encode proteins, forcing the remodeling of biological databases. But that's not the topic of this post.

What is the topic here, is how relationships can be stored in a database. Suppose I want to store mapping data: markers mapped to linkage groups, clones mapped to physical maps, ... Markers are stored in a markers table, clones are stored in a clones table, linkage groups in a linkage_groups table; you get the point.

The database that I'm working with at the moment (and only have read-access to), stores the mappings in a mappings table which includes the following columns:

  • map_type
  • map_name
  • mapped_object_type
  • mapped_object_name
So records could look like:
 map_type       map_id  map_name      mapped_object_type  mapped_object_id  mapped_object_name
--------------+-------+-------------+-------------------+-----------------+------------------
chromosome 1 chromosome_1 marker 1 marker_A
chromosome 1 chromosome_1 marker 2 marker_B
physical_map 2 ctg1 clone 1 clone_A
physical_map 3 ctg2 clone 2 clone_B


To make things worse, markers can also be mapped to clones. This means that any clone can act as a marker, but also as a map at the same time.
 map_type       map_id  map_name      mapped_object_type  mapped_object_id  mapped_object_name
--------------+-------+-------------+-------------------+-----------------+------------------
clone 1 clone_A marker 1 marker_A


How can I model this in ActiveRecord? There's the concept of polymorphisms in ruby, which could solve this relationship nightmare if there would be only one thing in the mappings table that's polymorphic. But as it happens, there's two... Evan Weaver wrote this rails plugin has_many_polymorphs, which should do the trick (see here for a tutorial and background if it's unclear what I'm talking about). Unfortunately, as it is focussed on rails and not on ActiveRecord in general, it doesn't handle namespaces.

So here's what I've come up with:

module MyNameSpace
class Mapping < ActiveRecord::Base
# Relationships to feature-like things
belongs_to :marker, :foreign_key => 'mapped_object_id', :conditions => ["mapped_object_type = 'marker'"]
belongs_to :clone, :foreign_key => 'mapped_object_id', :conditions => ["mapped_object_type = 'clone'"]

# Relationships to map-like things
belongs_to :chromosome, :foreign_key => 'map_id', :conditions => ["map_type = 'chromosome'"]
belongs_to :physical_map, :foreign_key => 'map_id', :conditions => ["map_type = 'physical_map'"]
belongs_to :clone, :foreign_key => 'map_id', :conditions => ["map_type = 'clone'"]
end

class Marker < ActiveRecord::Base
has_many :mappings_as_feature, :class_name => 'Mapping', :foreign_key => 'mapped_object_id', :conditions => "mapped_object_type = 'marker'"
has_many :chromosomes, :through => :mappings_as_feature
has_many :clones, :through => :mappings_as_feature
end

class Chromosome < ActiveRecord::Base
has_many :mappings_as_map, :class_name => 'Mapping', :foreign_key => 'map_id', :conditions => "map_type = 'chromosome'"
has_many :markers, :through => :mappings_as_map
end

class PhysicalMap < ActiveRecord::Base
has_many :mappings_as_map, :class_name => 'Mapping', :foreign_key => 'map_id', :conditions => "map_type = 'physical_map'"
has_many :clones, :through => :mappings_as_map
end

class Clone < ActiveRecord::Base
# Relationships where the clone is the feature
has_many :mappings_as_feature, :class_name => 'Mapping', :foreign_key => 'mapped_object_id', :conditions => "mapped_object_type = 'clone'"
has_many :physical_maps, :through => :mappings_as_feature

# Relationships where the clone is the map
has_many :mappings_as_map, :class_name => 'Mapping', :foreign_key => 'map_id', :conditions => "map_type = 'clone'"
has_many :markers, :through => :mappings_as_map
end
end


The key here is to make the distinguish between mappings_as_feature and mappings_as_map. A marker object can only have mappings where it acts as a feature, while a clone can both have mappings where it acts as a feature and where it acts as a map.

Using this code, it's now possible to do:

clone = Clone.find_by_name('clone_A')
puts clone.mappings_as_map.to_yaml
puts clone.mappings_as_feature.to_yaml
puts clone.markers.to_yaml
puts clone.physical_maps.to_yaml


Voila (until further notice...).

UPDATE: Pratik blogged about has_many_polymorphs and lists the generated associations here.

JungleDisk - online backup done right?

Posted over 6 years back at work.rowanhick.com

Following some links last week I ended up on jungledisk.com. All of 30 secs later I had the client downloaded and started backing up my hard drive. What is it ? It's a collection of clients for the 3 majors (Windows, OS X, Linux) that essentially mount up an S3 storage bucket as a separate volume. You purchase the jungledisk client for $20 after a trial period, then get an S3 account with Amazon.com and settle your bill with them, based on exactly how much transfer and disk space you use. Set the whole lot up, and bingo you have an online volume, that (one would hope) is near infallible. Over the past week I've had a mac connected up, and an xp box, to the same S3 account. I'm in the process of slowly backing up all of my very precious photos etc. You do need a fat pipe to go and store all this stuff online but that comes with the territory. The beauty of this system is it appears just as another volume, and with cross platform clients, it means you can have your data storage off in some other place, without worrying about it. The cost.. well, hardly anything to get worked up around. So far I've spent a princely sum this month of $0.16USD with Amazon for ~1gb transfer, and 300mb storage. I'm stoked. No iffy external hard drives, or optical media to get damaged. Of anyone I expect Amazon to be the most reliable service, much more than anyone could acheive with a SOHO RAID storage device, for a fraction of the cost. Very tidy solution, and well worth a look at.

The Talking Rails Application

Posted over 6 years back at Spejman On Rails

After a long time without publishing anything, I have finished an example of what you can do with festivaltts for Ruby: A Ruby on Rails application that talks!

You can test it at: http://thetalkingrailsapp.sergioespeja.com/

I hope it gives you ideas for your RoR applications!

Episode 69: Markaby in Helper

Posted over 6 years back at Railscasts

Do you ever need to generate HTML code in a helper method? Placing it directly in Ruby strings is not very pretty. Learn a great way to generate HTML through Markaby in this episode.