1. be_accepted, be_created, be_forbidden, be_found

    August 29th, 2007

    Little addition to your Rails test suite:

    module ActionController
      class AbstractResponse
        StatusCodes::SYMBOL_TO_STATUS_CODE.each do |symbol, code|
          define_method("#{symbol}?") { self.code == code.to_s } unless instance_methods.include?("#{symbol}?")
        end
      end
    end

    You can now assert your favorite status code:

    post :create, params
    assert response.created?

    And with RSpec, you too can be that glorious status code:

    post :create, params
    response.should be_created
  2. Rounded Corners - 139 (StainRank)

    August 29th, 2007

    At the cost of being customer friendly. Sounds like Deezer is heading for a bit of trouble. Here’s a company that’s building a great service around something people really want, one that’s a pleasure to use, priced just right. And they’re acquiring users by the boatload. So what could possibly go wrong with a strategy to please your target audience? Being in the music industry.

    StainRank. I just got hold of RESTful Web services: the Book. How good is it? There’s only one way to find out, as Engtech says:

    screw ISO documentation numbers. File everything by coffee rings. The most important documents have the most coffee rings

    I’ll give you the StainRank in a few weeks, but if you can’t wait, err on the side of buying one yourself.

    Just a friendly reminder. Andrew McAfee (via Stu):

    Sometimes, at least in part, it is about the technology.

    Beauty and brains. InfoWorld reports:

    Apple’s share of the laptop market is growing — the company now sells more than one in every six laptops purchased in the United States, a research firm said today.

    Yes, nice for Apple, but not exactly the headline I wanted to read. In times like this, it would be more reassuring if the headline read:

    One in six people in the US, smart enough to not buy a Windows PC.

    Camel race. Thanks to a Reddit link for pointing to this W3C discussion. They’re deliberating what names to choose for the upcoming DOM CSS selectors. I happen to think that’s important, but like too many standard works, this is done in small groups, based on pure speculation of what would be in the best interest of future generations.

    The other option is of course to ask developers using Prototype, jQuery, YUI-Ext or many of the other JavaScript libraries that already implement CSS selectors on the DOM, or get one of these tools, try them out and see how it feels. A little bit of coding home work could go a long way.

    What is it about technical committees that favor design by imagination even when there are working implementations?

  3. Dis or Dat (Mercurial and OpenID)

    August 27th, 2007

    Embracing: Mercurial.

    All the cool kids are doing it, so I figured there might be something behind it and start playing with it. Let me summarize my first impression of using Mercurial, granted for an early-stage small project with a development team of size N=1:

    I’d hate to go back to SVN.

    The biggest selling point for Mercurial is that it’s a distributed version control system, which quite frankly, I wish someone would explain to me in plain English. What I’m hooked about is how Mercurial does everything right.

    From the little things. It doesn’t version control directories, one of the more annoying SVN features. And it doesn’t spread .svn files all over the working copy, everything goes in one .ht directory at the root.

    To the bigger things. Your working copy is the repository, which means I can commit several times a day, and then when I’m ready synchronize with everyone else. Full version control without the broken trunk syndrome. And Mercurial is all about the changesets.

    In the SVN world you achieve changeset through the delicate act of juggling, either holding on to commits until you’re ready, or painfully branching and merging. None of that complexity indirection. Changesets is what you’re after, and changesets is what you get.

    Which, if it sounds too conceptual, don’t worry about it. The important point to remember is, once you go Mercurial, you’d hate switching back to SVN.

    Giving up: OpenID.

    As you probably heard, a few (headcount) people around the world got to experience the genuine “advantage” of WGA, namely the process by which a glitch on someone else’s computer turns your shiny new PC into the equivalent of a toaster over. Except it’s not even a good toaster over, you wouldn’t want to reheat yesterday’s pizza on its casing.

    It’s not pretty.

    As we all learned from reading SlashdotDigg, this only happens because Microsoft is an evil company. Although the exact technical reason is much more mundane, and does not involve strongly held beliefs in the moral characters of companies. The exact reason is what we often call “single point of failure”.

    Which is something that’s been bugging me — and if you read my posts from before you saw this coming — about OpenID. It’s a single point. And when that single point decides to go on vacation, which happens once in a while, not frequently but just often enough, it takes with it every other service that I OpenID login into.

    So no to that.

    I’m experimenting with OpenID for single sign-on behind the firewall, where both the applications and provider run on the same network, and you can fail-over the providers. Not sure how well that works, there are other problems it doesn’t address. But that much I know, the Web has too many technical challenges for OpenID, so I’m switching my accounts back to username/password.

  4. Dis or Dat (on Java)

    August 26th, 2007

    Not for the love of Erlang, but …

    Sometimes it only takes one sentence to summarize an entire post, even a good one as this:

    Really, that right there should be a clear indicator of how ill regarded Java development has become that people are willing to embrace the insanity that is Erlang in order to avoid using it.

    Kudos to Russell for not naming ships or referencing seating apparatus.

    Although there’s something to be said for “ill regarded” …

    You mean, like, lines of code?

    When you’re buying developers by the pound, it’s logical to treat them as machines that convert mouse clicks into code. Here’s an article that talks about a new way to write SQL queries, a very poor and badly done attempt to implement LINQ using Java.

    Though that itself is not the problem. It’s the fact that the article is void of any code, illustrated entirely through Eclipse screenshots.

    For the downfall of Java, Eclipse should take some of the blame.

    Illustrated espresso drinks, nothing to do with Java the language.

  5. Performance art on comp.compression

    August 26th, 2007

    This thread starts innocent enough, typical loon invents the perpetual machine equivalent of a compression algorithm and solves the unsolvable:

    The FAQ has been pointed out to me where it “proves” that not all files can be compressed by any algorithm, but it seems to me that it has some mistakes. They aren’t serious, but they are oversights that prevent it from applying to fractal bits, permutations and sorting the bytes of the original file.

    Said loon immediately encounters resistance from a likely source, your typical “between kill filing you and being nasty, I choose door no. 2“:

    > Good day everyone,
    Well it was a good day…

    The discussion quickly evolves into theories of compressions, fractals, perfect numbers and a bunch of other complex statements, none of which I can validate for myself, and arguments regarding sexual practices, none of which I can validate either.

    So far, a typical day on Usenet.

    But you want to keep reading, because half way through the thread suddenly takes a turn for the better — or worse — when it turns out our new compression wizard is motivated by more than the basic desire to create a better compression algorithm.

    Can’t say, though, whether it’s winning the Darwin awards, or pulling out a brilliant prank:

    Well, Jim, I don’t know “most people” are about, but in this case I really would like the decompressor. What motivated all this was a lack of space on my Hard Drive where none of the off-the-shelf compressors could save enough space. The fractal compressor I wrote was perfect (and I could prove its correctness too). I was able to squeeze down several Gigabytes of data to fix my space issues for now.
    The files in question are a lot of personal correspondance, research, and coursework archives. It’s nothing terribly critical, but still it’s stuff I’ve saved for years and which I’d really like to get back : (. The decompressor must be out there, it *has* to be. I don’t know what these other people you’re talking about did, but no one will try harder than I will to write it.
    I’m very optimistic (I still have all the compressed files sitting right here, the data is in them in some form), but I’ll keep you guys posted no matter what. You deserve no less, I suppose.

    In other words:

    You deleted the originals without testing a working decompresser first?

    Hilarious.

    The pessimist in me is appreciating the fact that none of that research material will see the light of day. The optimistic in me is wondering what brilliance is required to pull the collective leg of an entire Usenet group.

    Of course I keep reading further, mostly for the train wreck effect, but seriously hoping to find it’s a prank after all, not expecting it to turn into a brilliant piece of performance art about the state of scientific discourse in the US:

    Thanks everyone, for your polite comments. I think the takeaway from this for all of us is that voices have been heard on both sides in this thread illustrating the healthy debate among experts on whether random data can be compressed.

    Brilliant.

  6. To ESB or not to ESB?

    August 26th, 2007

    Somewhere there’s a post waiting to be finished, but for lack of time, we’ll have to do with this.

    My favorite ESB pattern which I would gladly recommend to anyone who asks looking for advise on how to reap the benefits is this, and the reference to Art of War is intentional: inform the competition how successful your ESB implementation is, and avoid using it yourself.

    It invariably leads you down the road to Product Oriented Architecture, the exact opposite of where you want to go. No technical reason for that, just the very idea that you can check mark a way to develop software by merely installing a product, which ends up being the fire for every project moth.

    But this one took my by surprise. A well articulated article on the ESB.delete pattern, coming from International Busybee Machines:

    ESB-oriented architecture is inherently flawed in that it builds connectivity no one might ever want to use. The business does not derive additional value until systems connect to each other and are working together. Until then, the ESB is just cost with no benefit. It might make the IT department feel good because they have built something, but it will not make the business feel any better, because the business is not accomplishing anything it couldn’t have already accomplished without the ESB. The ESB becomes the equivalent of a human appendix for the IT department, a vestigial organ within the topology of deployed applications.

    Of all the unlikey places …

  7. Vanity licenses and just saying “no”

    August 24th, 2007

    Kosher but stinks.

    That’s what I think of Microsoft using the OSI to rubber stamp their may-share licenses. It all boils down to this. Green is the new black, and open source is the new killer feature, and if you’re playing in the enterprise space, you better have it checkmarked on your feature list.

    But there’s only three ways you can get it on a PowerPoint slide and still keep a straight face.

    You can use a lot of open source software, which is a good idea because now you’re building on solid work, and putting your money where your mouth is. And it’s the easiest step from being user to becoming a contributor, and we want more of that. It’s also not an option for Redmond, their business model is based on eating their own dogs.

    You can produce tons of it, or having produced, put it out there. That’s not Microsoft either. Which is fine, it works for some companies and not others, and if I was Microsoft I wouldn’t be giving away my lock-ins either. Let’s just say WallStreet does not reward you for being an upstanding citizen.

    You can do some, but that just doesn’t cut it. Itemizing your open source lines of code doesn’t get you the coveted checkbox. Now you have two problems. You need to explain to the CEO what the free Outlook plugin you’re giving away does. Not going to happen. And you need to talk about the elephant: how much that discounted Exchange license will really cost the company. Itemizing is hard, people don’t get half pregnant.

    Which leaves us with the third, and easiest option of all. Get you very own OSI-certified license. Act now, while supply lasts, and you can get two for the price of one!

    You get instant “look, me too” cred, and you don’t have to sweat releasing any code. You’re certified now, the rest is implementation details. If you’re nice, you can throw out some unimportant code at the masses, or give your copy of what’s already free, and get a few free PRs.

    Which in a nutshell is what this hoopla is about.

    I’m not entirely clear what the OSI wants to do when it grows up, but if it’s about serving the community, then it needs to get out of the stamping business. Which, actually, has nothing to do with Microsoft, just a good opportunity to point out that the Emperor forgot to put on pants and it’s all hanging out.

    And it ain’t pretty.

    Vanity belongs on license plates. Open source is about removing friction, not creating a combinatorial complexity. Where can I share this code? What can I use together? Can I ship this overseas? Will the credits roll fit on a 40″ screen? Who decided to use this library without talking to legal first? How many contributor agreements is too much?

    We need proof.

    We need to know there’s a community interest behind the license, that it’s not to glorify the company or the project, but something that many members want, even better, need to use. That you exhausted all other options and amongst the MITs and BSDs and GPLs and CPLs and artists and what have you not, have not found a single license that could possibly work.

    We need to stop the madness of licenses as marketing collateral. In this case, less is more.

    And special thanks to Sun, SugarCRM and others for returning their vanity license plates to the DMV.

  8. One eye on the browser, one eye on the console

    August 23rd, 2007

    Step 1. Drop this in lib/tasks/development.rake:

    task "server" do
      # Dump lines from the file to the console at the specified interval (in seconds).
      def tail(file_name, interval = 1)
        position = File.size(file_name)
        leftover = ""
        while true
          sleep interval
          File.open file_name do |file|
            file.seek position
            text = file.read
            lines = text[/([^n]*n)*/m]
            if lines.empty?
              leftover << text
            else
              puts (leftover + lines)
              leftover = text[lines.size..-1]
            end
            position = file.tell
          end
        end
      end
    
      pid = “#{RAILS_ROOT}/tmp/pids/mongrel.pid”
    
      trap “INT” do
        puts “Stopping mongrel”
        puts `mongrel_rails stop -P #{pid}`
        exit
      end
    
      puts “Starting mongrel, hit Ctrl-C to stop”
      puts `mongrel_rails start -d -e #{RAILS_ENV} -P #{pid}`
      tail “log/development.log”
    end

    Step 2. Start the server:

    rake start

    Step 3. Hit the browser, watch the log, hit Ctrl-C to kill.

    Update: If you’re using Sake (if not, what’s taking you so long?), you can skip step 1 and install it once for all your apps:

    sake -i http://pastie.caboo.se/90791.txt
  9. Rounded Corners - 138 (Snap!)

    August 23rd, 2007

    The case against OpenID. This is quite an extensive list of problems with OpenID. Some not that bad, and the list was compiled by a vendor, but even with a mountain of salt and turning a blind eye on some parts, I’m left with the impression that OpenID is an ideal in denial of real life lessons. (Via Engtech)

    I’m actually having fun implementing OpenID for a behind-the-firewall app, and although I have no clue what IssuesDone does, I appreciate the simple UI. But out there on the Web … is OpenID something we need to fix?

    The network is the … oh, whatever! As InfoWorld reports:

    Initial reactions to Sun’s ticker change were mostly unfavorable — “a terrible idea,” “a waste of money,” “a stupid move,” “a joke,” and “worst idea ever,” according to most of the comments appended to Schwartz’s blog. Commentators saw the Java ticker as limiting, not expressive of Sun’s overall product portfolio and also very much yesterday’s technology. While Java has been widely adopted, its ubiquity and its 12 years in the market add up to a dated technology, they wrote.

    So how well is Java doing? YTD, struggling to scale up. Must be some tough competition from another four-letter word.

    GigaOm has more fun with corporate restocking strategies:

    4. AT&T (T) to (IFON) because we all know what is juicing their market share and revenues.

    5. Yahoo (YHOO) to (NOGO), which is short for Not Google. You could also take it literally.

    Simply curly. Aristotle, not so impressed with Simple Publishing Protocol, though, ironically proves the point by losing all the markup in the first comment, poses a challenge:

    Or how about uploading a picture:

    curl -H 'Content-Type: image/jpeg' --data-binary @inurprotocolz.jpg https://labotes.org/publish

    That’s actually shorter! Errm, oops, I forgot SPP can’t even do that. :-)

    I have to admit, scared me for a second. But a brief man curl came up with:

    curl -F ‘content=@inurprotocolz.jpg;type=image/jpg’

    So slightly shorter and still no envelopes wasted.

    Presenting presenters. I think it’s a step in the right direction, and I for one welcome our presenters overlords.

    Deezer rocks. Having fun listening to my play list over the Web.

    Pet animal rubber bands. Arcane but cute.

  10. Rounded Corners - 137 (Old dogs, new tricks)

    August 23rd, 2007

    mashups facebook apps

    Mashups are so 2007!

    Wimpless. Gojko Adzic:

    It’s incredible how, for a profession based around telling machines how to perform dull and error-prone tasks instead of humans, so few programmers think about how to automate their own work.

    Try some ClickLess Interface.

    Bugwards compatible. I’m not sure who I’m quoting, can’t find their name on the blog, but the message is simple:

    So when considering Scala as a language of its own, perhaps it would be best if the Scala community looked past its Java roots. Instead, it should embark on a journey of its own, developing supporting libraries that make excellent use of the unique features it offers.

    Some people, when confronted with a new language, think “I know, I’ll run it on the JVM.” Now they have two problems. (Inspiration)

    So much for refactoring. Some languages are just not meant to be agile:

    When writing in a language that is impossible to test, it is only prudent to make the smallest change possible.

    From a comparison of C and LEGAL.

    Broken metaphors. The other day I caught Ismael “my only app is a Web browser” installing software on his Mac. Sacrilege I tell you! Can’t say I blame him, though. You just won’t find many ground breaking apps on the Web. Mostly it’s copying existing apps, losing the power features, slapping some social bling, and calling it 2.0. Are we all out of creativity and new ideas?

    puts life[rand]

    wife: Just spam mail.
    me: junk mail.
    wife: whatever.