b a d p o p c o r n

Ruby URI Percent Encoding

Written by Ben on March 30, 2007 | 1 Comment

CGI.escape and URI.escape are both available in the standard Ruby libraries for URL encoding. But which one should you use?

Here’s a quick note about the differences:

irb(main):001:0> require ‘cgi’
=> true
irb(main):002:0> require ‘uri’
=> true
irb(main):003:0> URI.escape(’Test Hi<>?/&;=:’)
=> “Test%20Hi%3C%3E?/&;=:”
irb(main):004:0> URI.escape(’Test Hi<>?/&;=:’, ‘&’)
=> “Test Hi<>?/%26;=:”
irb(main):005:0> CGI.escape(’Test Hi<>?/&;=:’)
=> “Test+Hi%3C%3E%3F%2F%26%3B%3D%3A”

Note that URI.escape fails to encode the ampersand… So definitely use CGI.escape if you want to safely encode a query parameter for net/http calls.

Posted in Ruby

1 Comment

Here at BadPopcorn, Inc. H.Q.

Written by Aaron on March 24, 2007 | 2 Comments

Welcome to the inagural post from Badpopcorn H.Q.

Located in the relaxed heart of Old Town Orange California. BadPopcorn now has a home.

Here is our lovely view of…a relatively generic street.

dscn0877.JPG

That thing to Ben’s left is still hanging there…I don’t believe any of us like it…but there were theories floated the it might be there for luck…and who are we to risk bad luck.

dscn0867.JPG

First day of work at the new office.

dscn0880.JPG

First meeting in the new office.

dscn0871.JPG

The weeks, and months ahead will be chock-full of planning, collaborating, and lots of other things, most of which will involve looking longingly into a screen and typing away on keyboards like the feet of a shirtless Irish folk dancer…from the nineties. Except we’ll all be wearing our shirts…and it’s not the nineties…and it’s fingers on keyboards…look there’s going to be lots of fast typing.

More Updates to Come…

Posted in Business

2 Comments

RDFa Complexities

Written by Ben on March 18, 2007 | 2 Comments

So I briefly read over the new draft of the RDFa Primer. It’s good overall, but Section 5 introduces unnecessary interpretation complexities.

I say BLEAH to the Section 5. I want “Keep It Simple, Stupid.” parsing. The nested layers make it harder for the parser to parse; it makes it harder for the lay person to understand RDFa (and to adopt, and to use).

I also REALLY don’t like the idea of intermixing the id and about attributes for use in defining the subjects & objects. Although the primer makes a case for it, I counter with this example:

<body about=”http://example.com/mydoc#section”>
<div id=”popup”>
The document was written by <span rel=”dc:author”>Tim</span>
</div>
<a onClick=”…”>Show PopUp</a>
</body>

The ‘popup’ id is overloaded. It’s the identifier for which the Javascript code looks up, and it’s also become the subject of the dc:author statement. The above fragment is also non-intuitive. I would expect <http://example.com/mydoc#section> dc:author ‘Tim’. Instead, I get <#popup> dc:author ‘Tim’.

Posted in Web, XML

2 Comments

RDFa in Ruby, a First Stab

Written by Ben on March 13, 2007 | 2 Comments

A new draft of RDFa [1] has been out for about a month now, and it got me to thinking about RDF again. This time, the geek in me saw the opportunity to use easily use RDF in my Atom based applications. Instead of using embedded micro formats in Atom Entries, I can create semantic relationship using preexisting ontologies (e.g. - DublinCore) in an easy to read format.

The XML generation side had near zero work thanks to Ruby On Rails’ rxml format. But I was lacking a parser to read in the RDF statements even though there were a few Ruby RDF Stores available. The only RDFa parser I found was written in Python– rdfadict.

So, I just set aside parts of the last two days and came up with my own super simple Ruby RDFa parser; I read and reread the RDFa Syntax draft document, which is still far from complete; I skipped implementation of parts of the spec: xml:base, reification, and nested CURIEs; and got something to just work. (Note: rdfadict uses XPath for its implementation. Instead, I used an iterative approach to traverse XML documents).

Basic parsing works; I also made it flexible enough for custom integration; I just need to spend time to write up the documentation and write up more test cases. I’ll move forward with it as the RDFa spec develops and when I get feedback from anyone that uses this library.

But for now, the code is hosted here: http://code.google.com/p/ruby-rdfa/.

Posted in Web

2 Comments

Friday Night…They Dine In Hell!

Written by Aaron on March 5, 2007 | 1 Comment

th-fcjg3000098.jpg

Anyone want to meet up to go see 300on Firday?

That’s really all I got

I’m indescribably psyched for the movie.

Ben, Corey…I can already see you smiling and nodding…through the internets I see it. (What the Fuck am I? Yoda?! Mmm through the internets I see it yeeesss Rock Ass it will!)

I am thinking of seeing it in the O.C. of course…I would be willing to brave the spectrum for this but as I said I am super-excited.

Who’s in?

Posted in Movies

1 Comment