InquiryLabs

Politics, Programming and Possibilities

Archive for May, 2008

Testing Wengo Visio

I had a couple of ideas with Apple’s iChat and started looking around for implementations of “my” idea. It turns out Wengo (a French company) has done something like what I imagined: video chat on the blog. I’ll try it here:

Update: It doesn’t look like it’s working. Hmph. Neat idea though.

Update 2: Let’s try Stickam instead:

Update 3: Or not. How about tokbox?

[removed tokbox widget for now]
Yep, Tokbox works! Cool.

Super Digg Feed

I love digg, but I can’t stand how they make me go to the site for every single article. Use this feed from Georgy Woods instead:

Super Digg Feed v2.0

And by the way, if you aren’t already using one, and if you visit several websites a day to “keep up on the news” or to find out if one of your friends has posted some news lately, you should definitely use a feed reader, like NewsFire on the Mac, or Google Reader on the web. (Leah, I’m talking to YOU :) )

I thought this was very interesting. The plans for the highway haven’t been well publicized, so this was a refreshing summary on the house floor of what’s going on by Rep. Marcy Kaptur from Ohio.

While I support progress in transportation and technology, the objection I have with this is in the foreign ownership of highway systems, and particularly in the undemocratic process by which the plans for its construction are being made. Without a democratic process and a voice to represent our interests, you can bet that our people will not be served well, and in fact, will lose big.

  • 0 Comments
  • Filed under: Politics
  • Flock Rocks

    I’m using Flock (1.2 beta) right now, and I have to say, I’m hooked.  Imagine the amazingness of FireFox, enhanced with the ability to keep in touch with all of your friends using facebook, flickr, digg and their blogs.  It’s like a special world-view just for me.

    When I open it up, I can see who’s added new photos to their flickr stream, or what friends are doing right now on facebook.  I just found out that my old buddy from Rock Creek, Adam Mars, went on a trip to Europe that I didn’t know about! :)

    I’ll play around with it for a little while longer and see if the two of us (me and Flock) have any “irreconcilable differences” before switching.  Anyway, nice job, Flock team!

    Simplifying Rails Fixtures with Contexts

    The Fixture Debate

    If any of the debates at the Mountain West RubyConf last March could be called “heated”, I’d say the hottest one came when we started to discuss unit tests and functional tests in Rails.  I might be reading my own story into things, but what I got out of the discussion was that there is a consensus surrounding the idea that unit tests are good, and we’re all glad that Rails ships with a testing suite, but the brittleness of testing with fixtures is something that has yet to be solved universally.

    The Flexible Solution, Redux

    I’ve approached this problem before and offered a “flexible fixtures” patch (twice) to the core team that never made it in.  (It’s ok, I’m not bitter… I just think it’s a higher priority than they do).  With that patch having long been laid aside, I offer here a simple fix that will add much of the same functionality with a small change (fewer than 20 lines of reasonable length) to your test_helper.rb file (see below).

    What you get is the ability to specify the directory (i.e. the “context”) from which to load certain fixtures. For example, you might have several fixtures that are always loaded (e.g. drop-down box data or other basic data that is required just for your app to run) and then several scenarios or contexts that rely on that base level of data.

    This is how your unit test would look using this “context_fixtures” call:

    class AccountingRulesTest < Test::Unit::TestCase
      context_fixtures "base", :cities, :countries, :holidays
      context_fixtures "three_clients", :users, :accounts, :transactions
    
      def test_transactional_banking
        # ... etc.
      end
    
      # ... etc.
    
    end
    

    You can use context_fixtures in your functional tests this way, too.  I organize my test/fixtures directory into subfolders such as test/fixtures/base, and test/fixtures/three_clients, etc.  Note that this solution is not as flexible as the “flexible fixtures” patch, since it still requires that the fixture files map one-to-one to the tables in your database.  As usual, however, it’s ok to choose not to load data into some tables.

    Keeping Your Deprecated Fixtures Around

    If you’re in the middle of a project and you realize that you need these contexts in order to reduce the complexity of writing tests, what do you do with the test cases and data that are already working just wonderfully?  You don’t want to have to discard those.  Instead, you could create your own custom TestCase classes, like this:

    module Test
      module Unit
        class DeprecatedFixturesTestCase < TestCase
          self.fixture_path =
            File.join(RAILS_ROOT,
                      "test", "deprecated_fixtures")
        end
      end
    end
    
    module ActionController
      class DeprecatedFixturesTestCase < TestCase
        self.fixture_path =
          File.join(RAILS_ROOT,
                    "test", "deprecated_fixtures")
      end
    end
    

    After adding the above code to your test_helper.rb file,

    1. Rename the current “fixtures” directory to “deprecated_fixtures”, and
    2. Use this DeprecatedFixturesTestCase class as the superclass of all of your “deprecated tests”.

    It took me just a minute or two to search and replace “TestCase” with “DeprecatedFixturesTestCase”. With that change, from here on out, just use the regular TestCase class for your new tests and use “context_fixtures” instead of “fixtures”.

    Context Fixture Source Code for “test_helper.rb”

    ENV["RAILS_ENV"] = "test"
    env = File.dirname(__FILE__) + "/../config/environment"
    require File.expand_path(env)
    require 'test_help'
    
    # Add a little more granularity to our fixture
    # directories so that we can load some fixtures from
    # one directory (context), and other fixtures from
    # other directories.
    class Fixtures < (RUBY_VERSION < '1.9' ? YAML::Omap : Hash)
      superclass_delegating_accessor :contexts
      self.contexts = {}
    
      alias context_free_initialize initialize
      def initialize(connection, table_name,
                     class_name, fixture_path,
                     file_filter = DEFAULT_FILTER_RE)
        if contexts.has_key?(table_name.to_s)
          fixture_path =
            File.join(RAILS_ROOT, "test", "fixtures",
                      contexts[table_name.to_s],
                      table_name.to_s)
        end
        context_free_initialize(
          connection, table_name,
          class_name, fixture_path,
          file_filter)
      end
    end
    
    module Test
      module Unit
        class TestCase
          self.use_transactional_fixtures = false
          self.use_instantiated_fixtures  = false
    
          # Provide the 'context_fixtures' class method
          # in conjunction with our modded Fixtures class
          # above.
          def self.context_fixtures(context, *fxtrs)
            fxtrs.each do |f|
              Fixtures.contexts[f.to_s] = context
            end
            fixtures *fxtrs
          end
        end
      end
    end

    Tags: , , ,

    I’m a fan of capitalism.  But increasingly, I have begun to see socialism in a light that has softened my view somewhat.

    As I blogged about earlier, you can take capitalism to its extreme and see that it doesn’t work at every level of society: what would it be like, I asked, if capitalism were employed at the family level of society?  It would be absurd to not have things in common, or to let the fastest children eat first and let the others starve.  But on the other hand, capitalism has clearly taken us (humanity) a long way—in fact, it is still at present the most efficient economic system in the world—but I wonder if some of its underlying assumptions might be changing.

    Adam Smith’s “invisible hand” is a remarkable product of the exchange that happens when an individual makes a prudent decision in behalf of him- or herself—more often than not, the decision also benefits society in a way that leads to progress for the whole.  In contrast to competition in the marketplace, however, cooperation is almost always more beneficial for the individuals and the group.  The problem is that cooperation does not scale.

    Things are changing, though.  Technology is shrinking the distance between people and cultures, and enabling us to see more, connect more, and even think better about large-scale problems (for example, see this visualization presentation by Hans Rosling on world statistics). Given this trend, what if cooperation could outsmart and outperform even the almighty market?  What if cooperation could become scalable on the level of a whole country, or even the entire planet?

    I think of capitalism as the most efficient system with the “lowest common denominator” for a large number of independently acting agents.  Because these agents (i.e. you and I) have no way of making intelligent decisions in behalf of people whom we don’t know and don’t understand (i.e. almost everyone else), then the best possible decision we can make is whatever will most benefit us and those we are aware of.  So capitalism can be a local “win” when it is moderated by good judgment and compassion.  On the flip side, though, capitalism is often harmful to many people even though the people doing the harm can’t see a direct connection between a decision and its effects.  (If you’d like a good example of this, see the documentary film, The Corporation. Many of the CEOs of large companies don’t know or don’t want to know what their bottom line is doing to people.)

    So you have this interesting paradox where smaller communities and even smaller families work on socialist principles—for example, having access to public parks, or sharing bedrooms, toys, food, living space, etc.—while the larger communities (corporations, multinationals, each of the states, and the federal government) are primarily working on capitalist principles.  Somewhere in the middle, these two ideologies meet and we have flames from both sides erupting into a firestorm of words and blame.  We have the Democratic party and the Republican party.  We have public schools, and private schools.  We have the USPS and we have Fedex.

    What I’m really curious about is whether or not technology—specifically internet-based social networking—can help bring these two apparently paradoxical ideologies into some kind of hybrid that is better than any system we’ve ever created.  One inspiring video was created by a professor of Cultural Anthropology, Michael Wesch, at Kansas State University which explains where the social web is now and where it’s taking us.  Have a look at Web 2.0 … The Machine is Us/ing Us:


    Professor Wesch brings home the idea that we are the machine.  It’s not just that we are using a computer anymore: we are creating something larger than ourselves—the computer is using us too.  This ties in very closely with the futurist ideas of Ray Kurzweil that I’ve been reading about.  In his book, The Singularity is Near, machines are described as an extension of what it means to be human.  The 1980s may have done us all a bit of a disservice by fixing us on a somewhat limited view of what a “robot” and “artificial intelligence” is.  Smarter and smarter programs are becoming a part of our everyday lives… whether it’s an automated flight system, or the bartering for electricity that happens at the utility company, or the massive flow of human information now available on the web.

    In short, I think it will soon be possible for us to solve the capitalism / socialism paradox by making it easier to know about and understand others and by increasing our capacity to reason about problems on a larger scale.  When these two ideals meet, then perhaps we will become an even more efficient and compassionate society by capitalizing on cooperation.

    Thanks to ReadWriteWeb for an excellent article on Social Media that pointed me to Wesch’s work.

    Tags: , , , , ,

  • 4 Comments
  • Filed under: Politics
  • ROTFL

    I had to watch it twice.

  • 0 Comments
  • Filed under: Uncategorized
  • All Hail Rubinius! Rails is Running!

    Some exciting news in the Ruby community has been reverberating today… Rails works in Rubinius!

    Congrats to all involved, and thanks to EngineYard for sponsoring the project as well.

    Republican “Brand” Problems

    I’ve heard a couple of commentators claim that the Republican Party (aka, President Bush’s party) has a “brand problem”. I think that’s putting it lightly.

    As Frank Rich notes in his brilliantly titled opinion piece at the New York Times, “McCain Can Run, but Bush Won’t Hide“, it seems that bringing in the party “big guns” such as Karl Rove and Dick Cheney only improve the Democrats chances of winning in local elections.

    Some people have rightly pointed out that the people of Mississipi did not vote for Obama when they elected a Democratic representative in that election (Obama lost against Hillary); but in any case, the Republican loss there does at least point to this sketchy “brand problem” we’ve been hearing about. It’s not a brand problem, of course, unless you think things like attacking a country, or undermining 800-year-old laws like Habeas Corpus is an image issue. The problem is that we’ve had a group of establishment representatives running the show for too long, willing to curry favor to the largest bidders.

    I lean toward traditional conservative values like those represented by Ron Paul, but in the current state of things, I’m much more for Obama than I am for McCain. Here’s a little video that makes it pretty clear how McCain has tried to alter his “brand” over the past year to appeal to more voters:



  • 0 Comments
  • Filed under: Politics
  • Tech Support is the New Handyman

    I just had a little revelation about my role in the world. I am the handyman of the 21st century—the Mr. Fixit of information technology. While I don’t boast that I have solutions to everything, I’ve come to accept that being a “computer geek” is a high demand position—not just in the corporate world, but in the home as well. And I really do like helping out. Here are a few recent experiences that brought me to see the light.

    While preparing for a trip to New York, my sister-in-law, Leah, emailed a letter to all of our family members to organize the agenda etc. One of the plans was to go to see a Broadway show while in NY. Leah asked if I would try to find discount tickets to a show since I seem to know all of the “good places” to look. Since we had just found discounted tickets to Wicked the week earlier, it seemed natural that I might find a similar offer in NY. Unfortunately, I wasn’t successful this time, but I felt honored to be the “guy who knows how to get cheap tickets.” Being able to navigate the web, it turns out, is a very useful skill even outside of the programming world.

    As I was driving to the airport this morning to drop Kelty off (she is going to NY for 3 weeks to be with her Mom), she mentioned how grateful she was that my line of work was so useful. Just yesterday, she had accidentally formatted our camera’s SD memory card, erasing gigabytes of irreplaceable pictures and video footage that we had taken recently. She was upset with herself for having done it, and having checked the Canon SD1100’s manual for hope, we had concluded that the photos were really gone. Well, almost. It turns out that even a “format” of the card will not erase the pictures (unless it’s a low-level format, which was not our case). Using a $21 card reader and this free but obscure software, we were able to recover all of our precious memories. Once again, tech skills came in handy.

    Then, just as I was sitting down to write this article, I got another call. This time, Leah’s computer would not shut down. Windows had gone through the shutdown procedure but had frozen at the last moment, leaving the system on (you know how it goes). Anyway, I explained that you can just hold the power button down for several seconds and it will force the computer to turn off. And so the opportunities to serve in the home flourish.

    What I feel must be something like the handyman’s feeling when he can fix a leaking faucet, replace the spring in the garbage can lid, or maybe rewire a light switch. It’s not that difficult, but the domain knowledge is just specialized enough that it seems somewhat magical to someone outside the domain.

    Do we have a new title for this new century handyman? I don’t know. Maybe you can just call me Mr. Fix IT. :)