Downtown Cartel, in partnership with Always Creative and Matt Fruge, will be launching DesiredHearts.com in the near future. Part of the unique value Desired Hearts is bringing to the online t-shirt business model is the idea of building a donation to charity into the price of the product. With every shirt purchased, a portion of the revenues will go towards a charity of the t-shirt designers choosing.

I have not seen this done in many cases online, but I do feel that it’s a socially responsible thing to do. If more businesses followed this model, where your dollars go directly to charities for things that affect us all, such as the American Cancer Society or Oxfam International, even a fractional percent of sales would add up really fast considering the $14 trillion economy we have in the US alone. The question, and risk of this model, is would you choose to shop at places where you knew that a fixed amount (5-10%) would be going to a charity - or would you shop around to save a few bucks?

An added value that can emerge from this model is the free marketing your products receive if you work in conjunction with the charities you are raising money for. For instance, if you donate $600/mo from your sales to a charity with a large distribution network, like Oxfam International or similar, there is a distinct possibility of having your products marketed throughout their extensive distribution network on a continual basis because of the benefit they receive from your increased sales.

Share your thoughts in the comments section below.

comments: 0

Posted August 11, 2008 by Cody Marx Bailey in Business, Events, projects with tags , , , .

I will be attending the Magic tradeshow in Las Vegas in two weeks. You may be thinking to yourself “Cody, you are a grown man, what are you doing playing Magic the Gathering”, but I’m proud to say that is not the case. Magic is the premeir, twice a year, tradeshow for the fashion industry.

So, now you may be asking yourself “Cody, you are involved with a software company, what are you doing going to a fashion tradeshow?”. I will be there with Desired Hearts, a t-shirt label for now, learning about the industry and promoting our soon-to-launch website that Downtown Cartel built.

I’ve been to a few fashion shows, and been to plenty of boutiques in the different metropolitan areas I’ve lived in, but I’ve never been on the “industry side” of things.

What I’m Expecting To Learn

I want to learn how the different companies pitch their ideas. How they separate themselves from each other. I’m also wondering if there is something to learn about how we do our own service/product pitches by looking at a wildly different industry. I’ll be taking lots of notes and really digging into the techniques.

I think it will be a wildly different type of tradeshow than I’m used to, to say the least. I mean Linux World doesn’t quite have the same sort of feel that this one will.

comments: 1

Posted July 9, 2008 by Ben Burkert in projects with tags , .

Regular expressions are a developer’s best friend. Seasoned programmers can wield regular expressions to extract structured information from often near random input. And Ruby’s explicit syntax for regular expressions makes adding a little order to your data chaos a pinch. Turns out, the syntax works well for the opposite as well — creating random data from simple expressions.

Randexp allows you to use regular expression to generate a random string that matches the regular expression. Say you have a model with a serial_number property that validates against a regular expression.

/XX\d{4}-\w-\d{5}/

With our regular expression, we can generate random strings that always matches this expression using the generate (or gen, for short) method.

/XX\d{4}-\w-\d{5}/.generate    #=> "XX3770-M-33114"

The generate and gen methods are added to the Regexp class when the regexp gem is required, and construct a Randexp object with the regex’s source, which is ‘reduced’ into a string. The Randgen class is used to generate the actual random values, which can be extended to allow for more complex expressions, which covered later.

Right now, there is support for the single character matchers: word(\w), whitespace(\s), and decimal(\d), along with literals and multiplicity operators(*, +, ?, {}). One caveat though, most expressions raise errors when combined with the * or + operator.

/Aa{3}h*!/.gen
# => RuntimeError: Sorry, "h*" is too vague, try setting a range: "h{0,3}"
 
/Aa{3}h{3,15}!/.gen
# => "Aaaahhhhh!"
 
/(never gonna (give you up|let you down), )*/.gen
# => RuntimeError: Sorry, "(...)*" is too vague, try setting a range:
 "(...){0, 3}"
 
/(never gonna (give you up|let you down), ){3,5}/.gen
# => "never gonna give you up, never gonna let you down, never gonna give
 you up, never gonna give you up, "

The exception being the word matcher, which is treated as a random word. If a specific length or range is given for a word matcher, a word of suitable length is generated.

/\w{10}/.gen  # a word with 10 letters
# => "Chaucerism"
 
/\w{5,15}/.gen
# => "cabalistic"

This is still a bit cryptic, but the [:method_name:] syntax can be used to clean it up a bit, which calls the class level method of the Randgen class.

/[:word:]/.gen
# => "deutomala"
 
/[:sentence:]/.gen
# => "Antiphonically electrotellurograph chromatype proczarist plumet"
 
/[:paragraph:]/.gen
# => "Sesquioxide conationalistic paragoge dingus unsteadfast tenophyte
 goetic phytonomy hebephrenia rix uninjured biventral.  Householdry clunk
 amateur ramekin baronet chirotonsory mythical hobbist semblative
 cubonavicular outbrother templeward thaumatology velutina dharmasmriti
 kassak.  Persecutor wudu bertie deputative carburant."

Extending Randgen

You can add class level methods to the Randgen class which can be used within your regular expression using the [:xxx:] syntax.

class Randgen
  def self.serial_number(options = {})
    /XX\d{4}-\w-\d{5}/.gen
  end
end
 
/[:serial_number:]/.gen
#=> "XX3770-M-33114"

Under the Hood

There are two major steps involved in generating the random string. First, the regular expression is converted into a nifty little s-expression with the Parser class that is stored in the Randexp instance.

Randexp.new("(a|b)\\w*").sexp
# => [:union,
           [:intersection,
             [:literal, "a"],
             [:literal, "b"]],
           [:quantify,
             [:random, :w],
           :*]]

This sexp is then ‘reduced’ to the random output by the Reducer class, which walks the sexp constructing the string.

Dictionary

Randomly generated words are not actually generated. Instead they are picked from a dictionary of words loaded from your local words file, which typically holds thousands of words. So it’s got plenty to choose from. The words are also mapped by size, allowing you to generate words of a specific length, or within a range.

/\w{2,6} \w{10,20}, inc/.gen
#=> "mold forethoughtfulness, inc"

Note Right now randexps looks for your words file in /usr/share/dict/ or /usr/dict/. This works on OSX and most *nix distros, although I had to create a symlink on gentoo. Windows users are S.O.L., unless there’s a way to get a words file with cygwin.

Installation & Use

It’s published on github’s gemserver for the time being, it will be on rubyforge soon as well. Here’s the command to install it from github’s gemserver. Note You must be running the latest version of rubygems for this to work.

gem sources -a http://gems.github.com/
gem install benburkert-randexp

Load randexp from irb with the following.

gem "benburkert-randexp"
require "randexp"

Raison d’ĂȘtre

I started writing randexp because of another gem I was working on, can_has_fixtures, yet another alternative to fixtures. CHF replaces fixtures by generating pseudo-random data for model instances. By itself, randexp probably isn’t very useful, but combined with a model generator it can be quite helpful.

User.fixture(:employee) {{
  :first_name => (first_name = Randgen.word).capitalize,
  :last_name => (last_name = Randgen.word).capitalize,
  :username => username = "#{last_name}#{first_name[0, 1]}",
  :email => /#{username}@(corp|subsidiary|partner)\.com/.gen,
  :ssn => /\d{3}-\d{2}-\d{4}/.gen,
  :addr1 => /\d{2,4} (\w+ ){1,3}(street|lane|way), \w+, \d{5}/.gen,
  :records => (1..5).of { Record.generate(:employee) }
}}
 
User.generate(:employee).ssn
  # => "735-50-9234"
User.generate(:employee).addr1
  # => "8829 yearbook way, unconvenable, 29290"

Pretty cool, especially when you start extending the Randgen class.

I’m about to start rewriting CHF due to a few nasty bugs caused by single table inheritance models on DataMapper edge. It will probably be DataMapper specific because DataMapper is now our ORM of choice. (you can follow along here, but right now it’s just vaporware).

comments: 2

Posted June 25, 2008 by Brian Smith in projects with tags , .

Granted I am over a month late on this, but I had a backlog on my podcasts (I currently have almost 600 unlistened podcasts). In episode #32 of the Rails Envy podcast they gave a shout out to can_has_auth. I just thought it was pretty cool and wanted to thank them for the mention. I met Jason and Gregg at last years Lone Star Ruby Conf and they are both solid guys, even if they chose to play werewolf instead of going out to 6th street. Here’s the link to the show notes for the podcast. Rails Envy #32

comments: 1