InquiryLabs

Politics, Programming and Possibilities

Ruby DocTest Wiki

Ruby DocTest now has wiki documentation. I think the “What Is It?” page is especially helpful, given that it provides an “example workflow”.

How to Legally Disobey the Law

Just change it! Like those darn Bush Republicans and some Democrats are trying to do today. But the constitution clearly does NOT allow this sort of fudging of the law—this is an “ex post facto” change of consequences, which is prohibited by article 1, section 9 of the constitution:

No bill of attainder or ex post facto Law shall be passed.

Basically, this retroactive immunity issue for the big telecommunication companies is Bush vs. the Constitution—if he has his way, then he and those who loyally supported his creeping control over our rights and freedoms will go unpunished. Everything will be swept under the carpet, as if it was 100% OK to work illegally with the government under the cover of secrecy and some winks and nods.

From a Democrats.com email this morning:

Now I must ask you to pick up your phone again and call your Representative right now to demand a NO vote on warrantless wiretapping. The vote will be Friday around noon, but please call no matter what time you get this. (The Congressional switchboard is open 24×7x365 and each office has voicemail.)

Steny Hoyer’s warrantless wiretapping bill is obscene because it gives complete immunity to the telcos that have spied on us illegally since 2001, as well as the Bush Administration officials who illegally asked them to break the law. And it lets them continue spying on us by creating Big Brother with a figleaf of meaningless “protections.”

On May 14, Democrats defeated a similar immunity bill 213-197. There is absolutely no reason for any Democrat to change his or her vote now except corrupt greed for telco campaign cash.

So call the Capitol switchboard at 202-224-3121 and ask for your House Representative (not Senators) by name, or find your House Representative’s name and direct dial by entering your address on the right side: usalone.com

Or, call Speaker Nancy Pelosi (202-225-0100) and ask her to push this back or take it off the schedule. According to Democracy for America:

Speaker Pelosi can still stop this bill.

As Speaker of the House, Nancy Pelosi can pull the bill from the floor and refuse to call a vote.

Call Speaker Pelosi right now and demand she stand up to President Bush and stop telecom immunity.

Speaker of the House Nancy Pelosi (202-225-0100)

Suggested Script:
“I’m calling to tell Speaker Pelosi I am depending on her to pull any bill from the floor that will ultimately grant immunity to telecommunications companies who illegally spied on Americans. Can I count on Speaker Pelosi to stand up to President Bush?”

  • 2 Comments
  • Filed under: Politics
  • jsTree for jQuery

    I’ll probably use this some day. Very nice editable tree for jQuery called jsTree.

    Conference Bot for Google Chat

    Our small company has wanted an easy way to have a permanent “chat room” on Google chat / Jabber while also allowing us to maintain our chat logs. I found confbot, a python script, and it seems just perfect for the job.

    Now I can use my regular IM program (Adium) within a private chat room. Nice!

    Introducing a new Ruby DocTest

    I’ve been in contact with the authors of two tools, doctest and rubydoctest, to bring a new, unified Ruby DocTest tool to the community.

    I am confident this tool will improve the quality of my own software, and I think it might help you too. The tool allows you to put tests right into ruby code (in the comments) and provides a way to reliably keep the tests up to date, right with the code.

    Here’s how it works (the following is taken from the doctests within Ruby DocTest itself):

        # doctest: A statement should parse out a '>>' irb prompt
        # >> s = RubyDocTest::Statement.new([">> a = 1"])
        # >> s.source_code
        # => “a = 1″
        #
        # doctest: More than one line should get included,
        #    if indentation so indicates
        # >> s = RubyDocTest::Statement.new([">> b = 1 +", " 1",
        #    "not part of the statement"])
        # >> s.source_code
        # => “b = 1 +\n1″
        #
        # doctest: Lines indented by ?> should have the ?> removed.
        # >> s = RubyDocTest::Statement.new([">> b = 1 +", "?> 1"])
        # >> s.source_code
        # => “b = 1 +\n1″
    

    The “doctest:” directive gives the test a name. The “>>” marker says “execute this code” and the “=>” marker says “compare the result with the following expectation”. These markers are taken directly from irb, which–wonder of wonders–means you can copy-paste an irb session into your code and have that become your test.

    You can also put a “!!!” marker anywhere in the comments (it has to be the first thing after the #, actually) and it will take you into an interactive ruby (irb) session. For example, let’s say you had this much working:

        # >> s = "hello, my name is Simon"
    

    and you realize you don’t know how to use the [] regexp notation on this string (for example). You could add:

        # >> s = "hello, my name is Simon"
        # !!!
    

    then run the test suite (e.g. run “rubydoctest yourfile.rb”) and then the tests will execute up to that point and take you into the irb session where “s” is available to be played with. Then you can copy / paste the result back to your code and you have a working test.

    To install it:

    git clone git://github.com/canadaduane/\
    	rubydoctest.git rubydoctest
    cd rubydoctest
    rake manifest:refresh
    rake gem
    sudo rake install
    

    This will give you the “rubydoctest” command line tool.

    Enjoy!

    More Economic Woes to Come?

    The Royal Bank of Scotland recently issued a warning that they see a serious problem (i.e. a “crash”) coming to financial markets in the next 3 months. According to the Telegraph article, the warning comes from Mr. Janjuah who was correctly predicted the credit crunch that began last August.

    The author of the article, Evans-Pritchard is a bear on these matters, so we can expect some bias in that direction. But hey, so am I… it looks like we have something in common ;)

  • 0 Comments
  • Filed under: Economy
  • Incredible Photos from the Iowa Floods

    The first one got my attention.

  • 0 Comments
  • Filed under: Uncategorized
  • Family Connect, Updated by Steve Hulet

    Several years ago, I built Family Connect for Rails 1.0. Time has flown since then, and I haven’t updated the project one wit. But recently, Steve Hulet came along and brought the code base up to date with Rails 2.

    Steve wrote to say:

    I put the changes up on Guido Van Rossum’s new Code Review tool:

    http://codereview.appspot.com/2323

    There you can see fancy side-by-side diffs and enter any comments you may have.

    Thanks, Steve!

    It’s Firefox 3 Day!

    Today’s the day to download Firefox 3! I’ve been using the beta and release candidate versions for about a month now, and all I can say is “Don’t look back!” It’s much faster (really, it’s fast, especially on the Mac) and it’s also a lot more stable. I haven’t had it consume memory resources like FF 2.5, nor have I had it crash as often.

    Apparently the download starts at 11 AM MDT, so when the clock strikes, go download.

    Update: Here’s a great summary of the changes and new features.

    Some jQuery Notes on Querying

    I’ve had some time to use jQuery now and I’ve really liked it. I especially appreciated Yehuda’s comment on my blog earlier that lead me to try out livequery. I’ll never see app development in javascript the same way (thanks, wycats!).

    While I don’t have time to blog about livequery this morning, I would like to drop a few tips that I’ve picked up as I’ve used the powerful querying system that is jQuery.

    1. When using the ‘prev + next’ selector, you might think that this type of query is only useful for getting a set of the ‘next’ elements. Actually, you can get the set of next elements, and then ask for the ‘prev’ of each one:

    $(label + input).prev().css(font-weight, bold)
    

    The above code will make bold all labels that are followed by an ‘input’ tag.

    2. Logical AND, OR and NOT are possible in jQuery’s using set commands and/or its query language. The following couplets are equivalent:

    AND:

    $(.class-a.class-b)
    $(.class-a).filter(.class-b)
    

    OR:

    $(.class-a,.class-b)
    $(.class-a).add(.class-b)
    

    NOT:

    $(.class-a:not(.class-b))
    $(.class-a).not(.class-b)