I’m Porticus! I’m Porticus!

I have yet to start using the popular package management system Homebrew (brew install postgres), so I was happy to find the simple, graphical Porticus package browser, written by a Richard Laing.

Porticus is a Cocoa GUI for the MacPorts package manager

A longer Linux Journal article has details. Oh, like journalism.

I can’t find Mr Laing’s web presence anywhere. A helpful soul, who hides. Wonderful. A moment later, I found a long list of Dicks (Laing, that is). Great, now there’s a haystack of Laingses.

Problem compunded. Done.

Using find

When not using ack, my favorite search tool, you can still exclude SVN folders. Here is an example of me looking for a file:

$ find . -not \( -name .svn -prune \) -name 'EosController*'
./web/models/controllers/EosController.php
./web/models/controllers/EosControllerTest.php

This mode of expression might be better for your scripting needs.

Workstyle: Add vendor tests before using new library code

Hello again. Here is a snag-resolving article about a maintenance problem. There should be a thick volume called “Web Maintenance Pearls”, which everyone should be forced to read.

Here’s the situation: You want to throw out a dependency. It’s an older JavaScript library, and you have a replacement lined up. Some plugin for a popular framework that you already depend on.

Add a couple of jsTestDriver “VendorTests” test cases: proof that the new library works as advertised, defined without the noise of your application’s behavior. This test will run faster than manually testing your web GUI.

Write the vendor behavior test:


/** Tests of used vendor framework functions. */
var VendorTests = TestCase("VendorTests", {

    /**
     * MochiKit & the jQuery BBQ plugin should have the same URL querystring-
     * parsing functionality.
     */
    testMochiKitAndJqueryBBQWorkTheSame : function(){
        var qs = 'elvis=1977&reagan=2004&lee=1973',
            ob = {elvis:1977, reagan:2004, lee:1973},
            mObj = MochiKit.Base.parseQueryString(qs),
            jObj = jQuery.deparam(qs),
            mQs = '',
            jQs = '';
        
        //jstestdriver.console.log("JsTestDriver", "Elvis died in 1977:"+jObj.elvis);
        assertEquals(1977, jObj.elvis);
        assertEquals(2004, mObj.reagan);
        assertEquals(mObj, jObj);
        
        mQs = MochiKit.Base.queryString(ob);
        jQs = jQuery.param(ob);
        assertEquals(mQs, jQs);
    }
});

If you want to learn much more about hard maintenance problems, and how to crawl out from under them, read Michael Feathers.

That was the gist of it.

Snag expansion: Perhaps the jsTestDriver functions get overwritten, by code you import

As you include your target dependency – MochiKit – in your list of imported JavaScript files, all your tests still pass. A good sign. You add an empty test-case, with a fail("Good. If this is NOT seen, it means is trouble!");, just to see if the testing tool picks it up. All tests, including the new one, pass. A bad sign. Good thing you were suspicious. Paranoid, almost.

What just happened, and how to fix it:

  • MochiKit exported all its functions to the global namespace, by default. This includes name-clashing functions that thrash jsTestDriver’s same-name functions. Thanks to brasetvik for noting!
  • You can turn off that default behavior. Add this single line of code to a file, say initMochiKitWithoutGlobals.js: MochiKit = {__export__: false};
  • Include the new JS file in the jsTestDriver.conf “load” section, just before MochiKit:

server: http://localhost:9876

load:
  - web/scripts/jquery.js
  - web/scripts/tk/mochikit/initMochiKitWithoutGlobals.js
  - web/scripts/tk/mochikit/packed/MochiKit/MochiKit.js
  - web/scripts/jquery.ba-bbq.js
  - web/scripts/your_web_application.js
  - tests/js/your_web_application/*.js

Update: Currently, my way of making MochiKit.js be non-export configured, is to add the MochiKit = {__export__: false}; line instead of the initial MochiKit = {}; in the MochiKit.js file itself. (Since I’m moving away from that library, I figured it’s a cost I can take. It’s not like I’ll upgrade it, anyway.) Researching why that variable does not seem to get persisted, perhaps it’s a load order snag of some kind. window.MochiKit did not work. Hm. I’ll let you know when I nail it.

So, now your testing library runs correctly again. Cursed be global namespace pollution.

Thank you, MacPorts: How to add OpenSSL support to your PHP

Many interesting web APIs require SSL, for instance Google’s GData API. This adds OpenSSL support to your MacPorts-installed PHP, so that you can use the “ssl” transport layer:

sudo port install php5-openssl

Done.

Thanks, jmr_mp in the MacPorts IRC channel, for telling me about the existence of this short and neat patch-applying port, so that I could spare you, dear reader, from an introductory tutorial on how to edit Portfiles that don’t add the bells and whistles that you want. I had one written, but the above is saner. There’s always another hood underneath the hood. You don’t have to fix everything. Some things should just be fixed by the package system.

Here’s that Portfile:

$ port cat php5-openssl
# $Id: Portfile 69619 2010-07-11 03:00:23Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               php5extension 1.0

php5extension.setup     openssl 5.3.2 bundled
revision                1
categories-append       devel security
platforms               darwin
maintainers             ryandesign

description             a PHP interface to OpenSSL signature-generation \
                        and -verification and data-encryption and \
                        -decryption functions

long_description        ${description}

checksums               md5     46f500816125202c48a458d0133254a4 \
                        sha1    79ea4ee3da3a7542d1e348ac963a5b38bcbb4b6b \
                        rmd160  60a8aac0d51511ecaf8dcad9d31bdf072c0c99cf

depends_lib-append      port:openssl

post-extract {
    move ${build.dir}/config0.m4 ${build.dir}/config.m4
}

configure.args-append   --with-openssl=${prefix}

platform macosx {
    configure.args-append --with-kerberos=/usr
}

use_parallel_build      yes

Random ruleset: Guidelines for my bank’s credit card image customization

I’m a sucker for customization. Here’s a random thing. My bank’s rules for VISA card image settings:

Riktlinjer och regler för användning av egen bild:

  • Bilden fÃ¥r inte kränka annans upphovsrätt, rätt till varumärke eller annan liknande rättighet och ska följa god sed. Detta innebär att bl a följande regler mÃ¥ste följas för att en bild ska kunna godkännas.
  • Bilden fÃ¥r inte innehÃ¥lla företagsnamn, föreningsnamn eller kännetecken för företag eller föreningar, eller varumärken, logotyper eller mönsterskyddade produkter.
  • Bilden fÃ¥r inte innehÃ¥lla reklam eller syfta pÃ¥ nÃ¥gon med bankens tjänster konkurrerande produkt.
  • Bilden fÃ¥r inte föreställa offentliga personer, som t ex politiker, musiker eller idrottsmän.
  • Bilden fÃ¥r inte föreställa nÃ¥gon identifierbar person utan dennes medgivande.
  • Bilden fÃ¥r inte innehÃ¥lla motiv eller värderingar av samhällsfientligt, olagligt, rasistiskt, politiskt eller religiöst slag.
  • Bilden fÃ¥r inte visa personer involverade i olagliga eller rasistiska aktiviteter.
  • Bilden fÃ¥r inte innehÃ¥lla svenska eller utländska texter, siffror och symboler, ej heller personliga data eller webbadresser.
  • Bilden fÃ¥r inte innehÃ¥lla inslag av vapen och militära fordon eller av alkohol, tobak eller andra droger.
  • Bilden fÃ¥r inte ha provokativa, sexuella eller stötande inslag.
  • Bilden fÃ¥r inte innehÃ¥lla nakna eller halvnakna vuxna eller barn.
  • Bilden fÃ¥r inte kunna uppfattas som vÃ¥ldsam eller obscen.
  • Bilden fÃ¥r inte skapa säkerhetsmässiga eller andra problem vid användning av kortet, t ex fÃ¥r inte sedlar och mynt visas.
  • Bilden fÃ¥r inte utformas sÃ¥ att kortet uppfattas som vitt eller guld- eller silverfärgat.

NoSQL meeting report

So I went to a NoSQLSummer meeting yesterday night. Upon entering the deathly empty MINC complex, I thought “startups never sleep?”, but I found most of Neo’s staff in a cosy war-room called “Innovation Lab”. No coffee, but soda bottles. Copies of the paper were spread around the large table.

We met. We hung out. And, walked through the *Dynamo paper*, which was released in 2007, and is quite self-contained. That makes it “a NoSQL classic”. Good paper with which to open a reading circle. Now we have some pre-understanding for upcoming papers.

Photo by kalavinka

Other content

Neo4J’s Peter Neubauer, riffed on on Google’s data hugeness, which led us further afield: Google / Big Data; Crowdsourcing — WordNet; Concept: Discard 99% of the data, using the top 1%.

Thoughts on format

We’re currently toying with new/different perspectives/formats:

  • “Developer Perspective”
  • “Infrastructure/Scaling Perspective”
  • “Arch. Perspective”
  • “Apps/Ops Perspective”

Polyglot cases: How do you work with several multi-database setups?

Event bus usage: Some people use NoSQL stuff for the event buses. What are pros and cons here?

Do you need anything else there? I really enjoy this peek behind the scenes, implementation problems, etc. It is not something I can bring directly to my workplace and use, but I like the challenge of understanding large concepts together. The current format suits me well.a

Some hints and tips I picked up:

Google’s research end-of-level boss Peter Norvig’s talk at Berkeley (YouTube you-feel-lucky) — summarizing all the fields of research. (His official title is Director of Search Quality.)

A question: Is Stepanov’s Elements of Programming any good? Is it for me? (C++, math, beautiful type-setting.)

Next paper?

Google’s Bigtable? Cassandra? I cheated, and begun reading the Cassandra one. Let’s see how that goes.