2006

You are currently browsing the yearly archive for 2006.

  1. plug new digital camera into usb
  2. run gphoto2… get error (something about kernel)
  3. try digikam. error connecting
  4. try konqueror. nothing detected.
  5. unplug camera, repeat process with a vague sense of futility
  6. remove SD card from aforementioned camera, try plugging into internal card reader in laptop
  7. when nothing happens, spend 45 mins reading about internal card readers only to discover they’re generally not supported well. fail miserably getting anything to happen there
  8. give up on SD card, return to camera, plug in usb again and begin search for more info about specific model
  9. KDE automatically detects USB mass storage and pops up a dialog… twice. in annoyance, select “do nothing”… twice
  10. Somehow Konqueror still opens, displaying the now-mounted usb storage device representing your camera, complete with photos ready and available to be copied.

That, my friends, is the true definition of frustration.

TradeMe might account for NZ’s highest percentage of internet traffic, but in my opinion, Fairfax have no hope in hell of a reasonable return on their investment, if my experience is anything to go by.

My wife has used TradeMe, for a year or two, to sell things we’re not using any more (a lot of baby stuff as my daughter got older). We’ve basically had a lot of positive feedback, and no negative. The experience has, generally, been pretty good, although we have had a couple of bad experiences with less than honest traders.
Anyway, she hadn’t used it for a few months, then sold a couple of larger value items, and our account went into deficit (to the tune of a bit over $20, I think). She forgot to tell me, so we didn’t “charge-up” our balance, and another few months (possibly 3?) rolled by. Went to use the account again, a month or so ago, only to discover our membership is no longer enabled.

Here’s where the problem with the lack of customer service comes into play: there is no info in the online help that tells you what to do in these cases, the only option is to send a message online, or use their $1.99 per minute help line. Despite the fact that it’s our fault, I have no interest in paying 1.99 per minute just to talk with some monkey to explain what happened, that we want to pay and re-enable our account.

So I sent a message using their contact form.

No reply.

So I sent another message.

No reply again.

I’ve even tried dropping a suggestion in their online equivalent of a suggestion box.

No reply.

Which is crazy. Because, here’s the thing: I -want- to pay. I want to give them my money. Not just to get back the positive ‘kharma’ associated with our account, but also because it’s a valid debt and I believe I should pay it.

Is it logical to close the account of a customer who has used your system for a few years (without any problems I can recall), because they screwed up and owe you a small amount of money? Isn’t it more logical to keep the account open, but stop them from trading (bidding or selling) until they pay the balance? That seems like a far more intelligent and customer-centric approach — but what do I know? I haven’t built a company up from scratch and sold it for a few hundred million.

So… TradeMe doesn’t want my money, and I’ve seen enough anecdotal evidence (forum postings and other commentary… albeit a few years old) on the web to indicate other people have also had problems when dealing with them. If that’s anything like debugging software (i.e. the obvious stuff is just the tip of the iceberg), then it doesn’t bode well for TradeMe’s future, and for Fairfax’s investment.

UPDATE: Months after sending the original message on TradeMe’s contact form, we finally heard back. It appears we can pay our bill (only $6 rather than $20 as I originally thought) by just ringing the Wellington office direct and paying by credit card. Which is considerably better than calling an 0900 number. Unfortunately, the email arrived just as we were leaving to go to Thailand on holiday for 5 weeks. Obviously been back a month now, but haven’t yet had a chance to ring. I figure since they took a few months to get back to us, there’s no rush for me to rip out the credit card… but will do asap. Have a couple of things to sell, although Ben’s looks interesting…

I’m just in the process of releasing an experimental version (0.9) of YAK which showcases the latest features, such as product options, removing the need for exec-php, a credit card payment form, and a few other requested changes.

This release should be viewed as -highly- experimental. If you release it into a production system, you are, quite frankly, raving bonkers and should be committed to the nearest psychiatric institution.

That said, hopefully someone will have a test system that they don’t mind trashing, and get back to me with some feedback. Check the main YAK page and you’ll note that the way you use the plugin has changed (using html comment placeholders instead of php function calls using exec-php), so upgrading will unfortunately be a time-consuming process. WARNING: documentation may not be quite as comprehensive as I’d like.

The next stable release of YAK to include this functionality will be the 1.0 release, but is unlikely to be out before Christmas, because I need more time to fully test the new features.

Ugh. motivation dropping… enthusiasm waning… (vague cinematic tribute to favourite Mystery Men character — Mr Furious)

Pre Christmas Blues have definitely set in. Serious inability to focus on the masses of stuff I have to get sorted before Xmas. Thank god, in 2 weeks time we’ll be in Bangkok, with ready-and-willing inlaws available for babysitting!! ;-) A social life… how curious.

Can’t wait for Gaeng Paa Gai (that’s Jungle Curry with Chicken if you’re not in the know), from S&P in Sathorn (favourite mid-range restaurant).

Wii

Is it just me, or does the soundtrack on the settings screen of the Nintendo Wii, sound a bit like the soundtrack for the movie Solaris? Or is it just the fact that both use bells?

NZ DMCA

Cory Doctorow (of BoingBoing fame) has posted that NZ is to get a DMCA type amendment to our Copyright Act.

Sure enough, in the text of the amendment:

introduce an offence (carrying a sentence of a fine not exceeding $150,000
or a term of imprisonment of up to 5 years, or both) for commercial
dealing in devices, services, or information designed to circumvent
technological protection measures:

I’m not convinced that Tizard’s amendment is as far reaching as the DMCA (though trying to compare the changes to the Act with the text of the US DMCA requires a perverse sort of masochism I’m not cursed with), but I can see Doctorow’s point:

This has been an unmitigated disaster in the US: not only has it totally failed to keep copyrighted works from being copied without permission (every “copy-protected” work ever released is available on P2P networks within minutes of its release), it has also created an anti-competitive marketplace where companies can sue their competitors for making compatible products

It would be interesting to hear what a lawyer thinks about the NZ equivalent of the DMCA to know if it could have the same “chilling effects“.

Even worse is the following:

It also potentially reduces rates of piracy as a result of clear guidance as to what constitutes infringement. Increased certainty is created by New Zealand’s law being more in line with our major trading partners.

1. Rubbish. There is no way it will “potentially reduce rates of piracy”. Piracy will continue no matter what. Where’s the evidence from European and US markets that these law changes have made any difference?

2. “New Zealand’s law being more in line with our major trading partners” — read that as “we’re being pressured by foreign interests and they’re dangling the free-trade carrot”

 

UPDATE: Stephen Marshal has written an interesting commentary on his blog (already slashdotted). One of the more salient points he makes is:

Much of the economic damage from music and movie piracy also appears to arise from the production and sale of counterfeit CDs and DVDs, something that is already easy prosecuted under the existing laws and of no relevance to digital copyright whatsoever. Its worrying to see the Government serve up industry propaganda as fact in this way and it suggests a passive acceptance of the position stated by commercial interests rather than a deeper analysis of the facts.

 

new article

Article thumbnail from ONLamp
My latest article — about using Spread from within the LAMP platform — has just been published in ONLamp: LAMP and the Spread Toolkit.


nuts!

jaw drop
http://www.bbspot.com/News/2006/11/home-theater-regulations.html

In related news, the New York Times has suggested that if you catch someone reading your newspaper over your shoulder on the subway, you should mug them and take $2.50 from their wallet then deliver said funds to the NYT offices on West 43rd, as it represents a significant loss of revenue….


My IHUG broadband has been abysmal lately. I’m getting dropped connections, slow performance, and generally an unacceptable service.

Just ran a couple of tests. Within NZ I got:

1. 984kbps / 132kbps
2. 1380kbps / 128kbps

To LA I got:

1. 138 / 129
2. 159 / 129

To NY I got:

1. 346 / 129
2. 279 / 129

Holy Crap!

The big question is, would I be any better running a piece of string between two yogurt containers? I think so!

I’ve been doing a bit of work on YAK recently. A couple of bug fixes — one major fix to support people who don’t have curl installed (uses fsockopen instead). The major changes on their way are:

  • order cancellation — reversing the quantity decrement that takes place during ordering
  • new order page with summary info and then a detail button to display more data
  • credit card payment page — for shops who are processing their own credit card payments (this also blanks out the credit card number when an order is cancelled or stock is sent, reducing the security risk)
  • product options — in other words, styles/colours and/or sizes. I’m currently investigating this and haven’t quite come up with a way that keeps things simple enough. Obviously quantities for the options will have to be kept in sync which makes the products page more complicated, not to mention the ordering process.

Everything except for product options is currently in subversion (use the repository version at your own risk since I haven’t done enough testing yet).

Awesome! An animated version of PvP is on its way

…but it’s $US19.95 for a subscription.

I mean, come on! I’m stuck with Pacific Pesos here. That’s like a million NZ dollars at the current rate of exchange (warning: extreme exaggeration alert).

In any case, this is officially the first time I’ve considered taking an online subscription…

Anyone getting the following error when compiling cedega:

undefined reference to `__stack_chk_fail’

Try editing the Makefile in miscemu and adding “-fno-stack-protector”. Thus:

CFLAGS = -g -O2 -Wall -mpreferred-stack-boundary=2 -fno-keep-static-consts -D__const=const -fno-strict-aliasing -Wa,–execstack -D__int8=char -D__int16=short -D__int32=int “-D__int64=long long”

becomes…

CFLAGS = -g -O2 -Wall -mpreferred-stack-boundary=2 -fno-stack-protector -fno-keep-static-consts -D__const=const -fno-strict-aliasing -Wa,–execstack -D__int8=char -D__int16=short -D__int32=int “-D__int64=long long”

I also added it to the root Makefile, but that appeared to make absolutely no difference. No guarantees it will sort all problems and/or even run after compiling, but it certainly got me past that problem.

Took a bit of googling and even then a bit more experimentation to figure that out. Hopefully this post might shortcut the searching for someone else…

PS. Came to a complete and rather painful halt with configuration shortly afterwards. Approaching the more-pain-than-fun limit, so about to give up…

Vodafone seems to be intent on proving that the duopoly that is Telecom+Vodafone != true competition, == bad service, and == overpricing. As evidenced by this article at Computerworld. They might have the design skillz… but that’s the end of it.

From Rod’s pictures (last link above), it looks like Telecom have the l33t tech skillz, but whomever designed the MiniMax device has the design skills of a small badger with one arm, worse than usual eyesight, and a propensity for garish colour schemes.

yokel

It’s refreshing to see that NZ is not the only country that can appoint clueless monkeys to ICT government departments:

http://bangkokpost.net/151106_Database/15Nov2006_data001.php

A quote from the article:

On the subject of open source software, he said the current government plan was a case of the blind leading the blind, as neither the people who are in charge nor the people in industry seem to know the dangers of open source software.

“With open source, there is no intellectual property. Anyone can use it and all your ideas become public domain. If nobody can make money from it, there will be no development and open source software quickly becomes outdated,” he said.

Apart from Linux, he claimed that most open source software is often abandoned and not developed, and leads to a lot of low-quality software with lots of bugs.

Hmmm…. “most open source software is often abandoned” apart from Linux?

How about…. Firefox, Thunderbird, OpenOffice, JBoss, Netbeans, Eclipse (huge), Jetty, Tomcat, Spread, Azureus, BitTorrent, Audacity, 7-zip, Abiword, etc, etc, etc? Go to SF.net’s statistics page and see the huge number of downloads of some of these projects.

In regard to low-quality software, I seem to recall, from an ACMqueue article a few months back, that there is no correlation between numbers of bugs and open source software. In fact, here’s a relevant quote:

This type of development has both advantages and disadvantages. In various cases OSS seems to have solved many of the problems of traditional software engineering methods, since it has been possible to produce reliable, high quality, and low-cost software in a brief amount of time. The existence of a large pool of testers and developers facilitates debugging and the true peer review of the code results in better code.

In fact, to say this guy is a clueless monkey is a bit of an insult to the clueless monkeys out there. My apologies, clueless monkeys!

My latest article, Getting Started with WSGI, (one of the numerous reasons I’ve been too busy to post lately) has just been published in O’Reilly’s ONLamp.

Actually, it’s not the main reason for not posting, since I wrote the piece back in July, but I’m still using it as an excuse until the next couple of projects come to fruition… ;-)

Gads!

And if that’s not bad enough:

EGAD:

…no, I’m not out of touch with the level of wealth in my own nation. Have you walked around a so-called “poor” neighborhood lately? I see big screens in almost every home…

1. I somehow doubt he’s been walking around in a -really- poor neighbourhood and,

2. let’s not forget the fact that it’s still possible for people on low incomes to get credit (only to have the items repossessed if they fail to meet the payments). We’ve got a similar problem here with banks extending 100% mortgages and the worry that when the market changes significantly, people with that kind of debt will be in serious financial difficulty… bringing me to,

3. what happens when you have all these debts and your financial circumstances change?

Frankly I can’t believe he’s promoting the idea of personal debt for an overpriced console, for god’s sake. Particularly when there is a (wii bit) cheaper, and potentially more fun, option.

Not posting too much lately because I’ve been busy with a couple of personal projects. Just thought I’d mention that YAK has hit the big 1000 downloads. Sure, doesn’t seem like a huge amount (microscopic compared to some OSS projects), but it’s my most successful open source project to date, so I’m quite pleased.

This is an excellent example of a developer getting carried away by his/her own cleverness:

When generating Java code from an XML Schema, in certain modes JAXB automagically converts words to plural where there may be more than one element. For example, the word Datum is automatically converted to Data, the word Item converted to Items.

This is an exceptionally bad idea for 2 reasons (off the top of my head):

1. Surely it makes more sense for the code to closely match the schema? Not arbitrarily deciding to fix your grammar for you.

2. It’s badly implemented. For example, if I have an abbreviated word ending with “f” it incorrectly converts to plural — “Itemref” becomes “Itemreves”. Garbage. What’s worse, is that I have an xsd:choice contain Items and Itemrefs, so the JAXB1 generated code contained the method “getItemOrItemRef” — JAXB2 in extensions mode creates the wonderful “getItemsAndItemreves” method.

What 1st university student on 6 months work experience came up with that brilliant plan?

But wait, it gets even worse. The jaxb documentation at dev.java.net is full of badly written (often unintelligible) ramblings, missing links, less-than-useless links to blog entries and unwritten faq entries (why bother writing the heading if you don’t have time to write the content, I ask you?).

It is, to put it politely, an absolute mess.

One of the more useful aspects of WordPress is its extensibility. It makes WP a powerful container for all sorts of applications.

I’m currently working on a WP-based project that requires access control of pages based upon a user’s roles, so I’ve come up with a simple plugin for providing this functionality (download here).

To use, install and activate the plugin. To secure a page, add a custom field “acl”, with the value set to a comma-separated list of roles (for example, “administrator,subscriber”). If the user is not logged in, or does not have one of those roles, they’ll see an access-denied message. The plugin will probably be more useful if coupled with Redalt’s RoleManager.

NOTE: considering this is in the very early stages of development, use at your own risk.

YAK bug

Rather painful bug in my wordpress plugin, YAK:

Allowed memory size of 8388608 bytes exhausted (tried to allocate 21 bytes

I understand what it means, but I don’t understand why it’s happening. As far as I can tell, I’m not allocating any large datasets — and the error only appears when I click the WP dashboard. I went through and commented out the entire core script, then uncommented bit by bit until it fell over. Then commented that function again, and uncommented the functions following it and the problem reappeared — which implies it’s something to do with the amount of functions/code I’m creating rather than what I’m doing in those functions (I think).

The short term fix is the following line in the beginning of the script yak.php:

ini_set("memory_limit", "10M");

Which unfortunately is treating the symptoms, and not the cause…

Tim said this (talking about using Ruby to generate Markup). Leon comes back with this (showing a more readable way to do it in Markaby). All well and good, but they’re talking about generating HTML markup, as much as generating generic XML. And, quite frankly, in the words of Ludo:

“SMELL BAD”

So what’s wrong with templating? Okay, I know next to nothing about Ruby (other than a brief look at a few tutorials, so far), so I might be (and probably am) completely missing the point — but the last time I had to programmatically generate HTML was… well, I can’t remember the last time. XML, yes. HTML, not in years.

What’s wrong with:

<html>
<head>
<title id="title">title here</title>
<link id="stylesheet" rel="stylesheet" href="" type="text/css">
</head>
<body>
    <h2 id="heading">heading here</h2>
    <p id="para">paragraph here</p>

    <ol>
        <li id="listitem">list items here
    </ol>
</body>
</html>

And something vaguely like the python code below; injecting the content based on the element IDs (note, the template engine I’m thinking of doesn’t completely support this functionality):

te = TemplateEngine.get('mytemplate.html')
te['title'] = 'Atom Protocol Exerciser Report'
te['stylesheet'].href = '/ape/ape.css'
te['heading'] = 'The Ape says:'
te['para'] = 'some paragraph I dynamically load up from some data source'
te['listitem'] = [ 'a', 'list', 'of', 'items' ]

I definitely think I’ve missed… some… point.

I’ve decided my blog is best served from my personal domain name, making my company domain basically just a business card with a few additional bits and pieces (like the ever-so-gradually expanding products page). Which means url’s now change to:

http://www.briggs.net.nz/log for the blog, and:

http://www.briggs.net.nz/log/feed for the feed.

Feel free to update links accordingly.

You’d think a Flight Centre “Risk Manager” would take into consideration the risk of extremely bad publicity from this story getting out and spreading…?

A couple of evenings hacking around with PHP extensions has reminded me exactly why I stopped doing C programming.

I’m trying to get an extension (which I’m interested in using), to compile and then to actually work — which is proving a challenge. In an attempt to figure out exactly where I’m going wrong, I’ve simplified the build process I documented here.

The following is based on a Codewalkers tutorial — modified to run in my environment (thus your mileage may vary).

The module source is:

#include "php.h"
#include "php_globals.h"
#include "ext/standard/php_string.h"

PHP_FUNCTION(mytest1);

static function_entry firstmod_functions[] = {
    PHP_FE(mytest1, NULL)
{NULL, NULL, NULL}
};

/* compiled module information */
zend_module_entry firstmod_module_entry = {
    #if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
    #endif
    "First Module",
    firstmod_functions,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    #if ZEND_MODULE_API_NO >= 20010901
    "0.1",
    #endif
    STANDARD_MODULE_PROPERTIES
};

ZEND_GET_MODULE(firstmod)

PHP_FUNCTION(mytest1) {
    RETURN_STRING("Hello World version 2", 1);
}

To build, issue the following commands (you may need to change the include paths to point to your php installation):

cc -fPIC -DPIC -DCOMPILE_DL=1 -I/usr/local/include -I.  -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/Zend -I/usr/include/php5/TSRM -I/usr/include/php5/ext -c -o first_module.o first_module.c

cc -shared -L/usr/local/lib -export-dynamic -avoid-version -rdynamic -o first_module.so first_module.o

Copy first_module.so to your php extensions lib dir, add to the ini file, and hopefully it should work.

Zend has a darn useful tutorial on creating php extensions. After a few false starts, I’ve managed to get something working, so I’m documenting my steps here for my own future reference.

Note 1: this is specific to my Kubuntu installation.
Note 2: I’m basically refactoring Zend’s hello world example to “mytest”… just because I can.

1. create a directory for the extension. In my case I’m creating a dir “mytest” in my homedir.

2. create a phpize configuration file (config.m4) in the mytest dir:

PHP_ARG_ENABLE(mytest, whether to enable mytest support,
[ --enable-mytest   Enable mytest support])

if test "$PHP_MYTEST" = "yes"; then
  AC_DEFINE(HAVE_MYTEST, 1, [Whether you have mytest])
  PHP_NEW_EXTENSION(mytest, mytest.c, $ext_shared)
fi

3. create the header file (php_mytest.h):

#ifndef PHP_MYTEST_H
#define PHP_MYTEST_H 1

#define PHP_MYTEST_VERSION "1.0"
#define PHP_MYTEST_EXTNAME "mytest"

PHP_FUNCTION(mytest);

extern zend_module_entry mytest_module_entry;
#define phpext_mytest_ptr &mytest_module_entry

#endif

4. Create the C file (mytest.c):

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_mytest.h"

static function_entry mytest_functions[] = {
PHP_FE(mytest, NULL) {
NULL, NULL, NULL}
};

zend_module_entry mytest_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
PHP_MYTEST_EXTNAME,
mytest_functions,
NULL,
NULL,
NULL,
NULL,
NULL,
#if ZEND_MODULE_API_NO >= 20010901
PHP_MYTEST_VERSION,
#endif
STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_MYTEST
ZEND_GET_MODULE(mytest)
#endif
PHP_FUNCTION(mytest) {
RETURN_STRING("Hello World", 1);
}

5. run the command phpize to create the configure and make scripts (and associated gumpf) — you’ll have to install php5-dev if you haven’t already:

apt-get install php5-dev

6. configure, then make the module:

 ./configure --enable-mytest
make

7. copy the extension to your extensions dir (which is defined in /etc/php5/apache/php.ini — or in my case it doesn’t seem to be, but nonetheless appears to be the directory: /usr/lib/php5/20051025)

8. add a directive for the shared object to the php.ini file. In this case:

extension=mytest.so

9. restart apache

10. create a php script:

&lt;?php
echo mytest();
?&gt;

11. Point your browser at it, and hopefully you should see “Hello World”.

Which is nowhere near as painful as I thought it was going to be. Result!

I’ve just changed web hosts (to WebFaction — formerly known as python-hosting). Liking their custom console, and particularly like having ssh access once again.

If anyone finds something missing or not working, please let me know.

Here’s a hotel to add to the list of places not to stay when in Bangkok: Swissotel Nai Lert Park.

My wife was just telling me a story she’s been reading on a Thai website, about a girl who booked a conference room at Nai Lert Park, for her wedding, months in advance. Three or four months before her wedding, she was contacted by hotel representatives asking to move to the gardens (for a reasonable discount). Someone ‘important’ wanted to use the larger conference room she had booked. She declined.

She was contacted again and again over the next few months. More discounts offered, for the use of the smaller conference rooms. She also declined moving to these (I imagine because that would affect the number of invitees).

Finally, a month before her wedding she was contacted once again, and given an ultimatum: either move to the garden or the smaller conference room. Once again she declined, feeling she was in the right because of her early booking.

The response of hotel management was to cancel her booking and return her deposit.

With an attitude like that, cross Nai Lert Park off the list of places I’ll ever stay. Lucky there are plenty of other awesome hotels to stay in, if I’m ever feeling exceedingly extravagant…

After a bit of googling, I have yet to find a command-line tool that simply handles HTTP requests. There’s wget for retrieving files, curl for PUT and POST, but what to use for DELETE (or other HTTP methods)? For that matter, I’d prefer to have a single tool, rather than 2 or 3.

I wrote a simple python script a while back — the last time I couldn’t find such a tool — and so now that I need to use it again, it seems like a good time to polish it up and release it (here). Not before chopping out a bunch of specific hacks that really need tidying up before being included in released code, of course.

So if you need a basic tool for handling HTTP requests (GET, PUT, POST, DELETE) you may find it useful… rather than having to write the few lines of code yourself.

Haven’t been posting much lately since I’ve been busy with a couple of projects, but I’ve just realised that today is the one month anniversary of my move to Kubuntu.

Overall the experience has been excellent. apt is hellaciously cool, and a 5 minute install for major updates sure beats the 5+ hour turnaround for Gentoo. The fact that it just works (unlike the nightmarish hell that I recall RPM being under Mandrake and Redhat) is an obvious bonus.

There are a few quirks when comparing the Kubuntu desktop experience with Gentoo, but nothing too drastic — and then again, Gentoo had its own quirks, so weighing up one set against the other, gut feeling tells me that Kubuntu still comes out on top.

On the whole Kubuntu is just that little bit more stable (although that’s perhaps an artifact of the more bleeding-edge nature of a typical Gentoo install), and best of all, my network now automatically switches between wired and wireless on bootup, which is something I never managed to get working successfully under Gentoo.

excellent: http://www.acmqueue.com/modules.php?name=Content&pa=showpage&pid=401

Just noticed on Jon Udell’s feed here, a story about WriteRoom — an editor which removes all distractions from the desktop to allow you to focus on the task at hand.

I think it’s a brilliant idea — weird thing is, I had the same idea independently, a year or so ago; having decided that there were way too many distractions in the average editor/word processor and that I’d get a lot more done if they were just gone.
As a consequence, I’ve been using my own ‘distraction-free’ editor (written in Python) for the last 6 months, always meaning to release the code, but never quite getting around to finishing it. Not sure if the idea actually works, but I do prefer writing in that environment rather than any of the alternatives, so I guess it does.

Anyway, in honour of WriteRoom, which looks a lot more polished than my completely unfinished effort, I thought I might as well release my own version (ued-0.5.zip, ued-0.5.tar.bz2) — making no warranties for its suitability for any task, stability, or anything else (i.e. use at your own risk… I am).

You’ll need python2.4 and pygtk2.0 or later to run it.

Usage:

  • CTRL+O - open a file
  • CTRL+S - save
  • CTRL+A - save-as
  • CTRL+W - show statistics
  • CTRL+1 - change editor font
  • CTRL+Q - quit
  • CTRL+F - find (as yet, there’s no find+replace)
  • CTRL+T - pop open the browser and lookup a word in thesaurus.com

One final note, it has its own basic versioning built-in - each time you save a file a backup is made (a DOT [.] file) in the same directory.

Every time I sit down to do something with mod_python, I have problems. Usually they can be traced to forgetting to RTFM.

It doesn’t help that I tend to put experimental code in my apache www dir on occasion — and forget to back it up — so that after a system reinstall, I then have to dredge the dim, dark recesses of my memory to remember how to do simple stuff.

So for my own future reference…

  1. a WSGI handler (wsgi_handler.py) for mod_python can be found here
  2. the handler needs to be accessible on the python path, so copying it to /usr/lib/python2.4/site-packages means it’s accessible (there’s a better way, but it momentarily escapes me)
  3. the apache config required is:
    <Directory /var/www/test>
    PythonHandler wsgi_handler
    PythonOption WSGI.Application hello::simple_app
    AddHandler python-program .py
    </Directory>
    

    Where:

    • /var/www/test is an absolute path to a directory I’m serving on the web
    • hello is a python script (hello.py — see below)
    • simple_app is a function in the script

    In the case of my kubuntu laptop, I just created a mod_python.conf file containing the above in /etc/apache2/mods-enabled

  4. hello.py, a simple WSGI app, looks like this (snaffled from the python PEP for WSGI):
    def simple_app(environ, start_response):
        status = '200 OK'
        response_headers = [('Content-type','text/plain')]
        start_response(status, response_headers)
        return ['Hello world!\n']
    
  5. restart apache, and hopefully we’re away…

I’ve also added an extension to make wsgi_handler slightly more useful for my purposes; the ability to serve more than one ‘app’ from the same script. The extended version can be found here.

The apache configuration can then be modified to:

<Directory /var/www/test>
PythonHandler wsgi_handler
PythonOption WSGI.Application hello
AddHandler python-program .py
</Directory>

And hello.py now looks like this:

def simple_app(environ, start_response):
    status = '200 OK'
    print str(environ)
    response_headers = [('Content-type','text/plain')]
    start_response(status, response_headers)
    return ['Hello WSGI world!\n']

def test(environ, start_response):
    status = '200 OK'
    response_headers = [('Content-Type','text/plain')]
    start_response(status, response_headers)
    return ['test test test\n']

Meaning that you can now point your browser to:

http://localhost/test/test.py/simple_app

or:

http://localhost/test/test.py/test

Which is useful for experimentation.

After 3 or 4 years (I forget quite how long now), I’m finally saying goodbye to Gentoo on the Desktop. I’m keeping a development server going with Gentoo, but yesterday came to the unfortunate conclusion that it was starting to cost more time than I was willing to put in for a desktop machine. I’ve always been just short of bleeding edge, so there’s an argument I could scale back my settings for a more stable environment — however when everything went completely pear-shaped after upgrading Xorg yesterday (and after it took an hour or so to recover Xorg6) it became apparent I needed something with a slightly faster install process. Half a day to rebuild X, kde and various other bits and pieces on Gentoo…? I don’t think so.

So I’m now in Kubuntu-land. Looks okay so far, and the network stuff seems to hang together a bit better than it did before. For example, I now don’t need to manually switch between wireless and wired connections — something I never got working satisfactorily on Gentoo. A few quirks on installation, but so far so good.

My own experience suggests that REST and Soap/WS is an apple and oranges comparison. Actually that’s being unfair to oranges. It’s more like an apple and strange-looking-fruit-bearing-no-resemblance-to-anything-palatable comparison.

When I’ve had the opportunity to design a system around REST principles (resource-oriented, POX, basic HTTP, etc), it has had a simplifying effect on the overall architecture — not dumbing things down, just a reduction in complexity. I’ve had to think differently about fundamental design issues — what are my resources, and how should they be interacted with… rather than RPC API details — in a way it’s a little like the difference between thinking OO terms and thinking procedurally.

The same can not be said for the SOAP/WS systems I’ve seen, and worked with, where complexity seems to be an accepted byproduct. BPEL, choreography, discovery, and the myriad other WS-* specifications are, to me, a good reason to sell expensive product, and justify business power lunches, but a bad way to design software. SOAP at its heart was a relatively simple idea, but there’s enough other crap bolted-on around it now to sink even the most bouyant of ships. There will be plenty of proponents who’ll argue the whole tooling angle — that their (obscenely expensive) tools will hide the implementation details from you. Well I’ve used some of their tools, and I’m definitely not sold. Just what the world needs: the equivalent of a Renault Alliance, with worse fuel economy than a Hummer, slower than a Simca 1000 running on 3 cylinders, and a Ferrari price tag to boot.
Not to forget that hiding away implementation details is a good way to cause a mass of problems when the client asks you to do something that fall just outside the capabilities of the tool.

All of which is to say I believe that positions which appear to argue the differences between REST and SOAP down to mere implementation details, are less than convincing. Okay, to be absolutely honest, I have argued something vaguely similar in the past… but I’m wavering on the cusp of thinking I should’ve explained myself a bit better. I still believe that a resource-oriented application could expose some SOAP-style services, but it certainly wouldn’t make sense for an entire application to expose dual interfacing. And I certainly don’t think that a WS-* design can then expose its methods as HTTP verbs and somehow magically satisfy the goals of a REST architecture (usage of HTTP verbs, alone, doth not a REST app make). A bit like an elephant trying to squeeze into a pair of hot-pants and then announcing to the world that it’s a prima ballerina.

Related footnote: I hadn’t read this before, but it’s a brilliant read.

Stefan has just posted a nice, simple illustration of the differences between service-oriented and resource-oriented (i.e. REST) design. Something to bookmark (which I’m doing right here… ;-) ) for the next time someone asks me what the hell REST is…

I notice that I can occasionally suffer from wrong-syntax-itus when switching between Python, Java and PHP; particularly when I’m caught up in the development moment. Although the more I get used to a language, the less this seems to occur.

However, there is an exception to this rule — the switch from SQL to HQL — my particular gripe du jour. I still find Hibernate’s Query Language a jarring wrench from thinking ‘relationally’, so to speak. For that matter, I also find it far more efficient to write queries in SQL (only to then suffer the pain of converting them to valid HQL — which is perhaps part of my problem).

Which brings to mind another gripe when moving between languages — the lack of features in one that are available in another. Case in point: the lack of multiline strings in Java. There’s nothing worse than a large SQL (or HQL) statement split over multiple lines in Java — the string could be included from a separate property file, but in my opinion, this makes the code more difficult to work with and it doesn’t easily explain itself on first glance. There’s a lot to be said for immediately readable code.

Having said that, I’ve thought of something worse: the hideous blight inflicted on code by complex Hibernate Criteria Queries.

This is one of the more useful hacks I’ve thrown together lately. It’s a simple console application for accessing a hibernate domain (i.e. you can execute queries such as “from Blah where x = 1″), so you don’t have to deploy your application to test minor changes to hql statements.

It is, by no means, an endorsement of hibernate; rather a reflection on the fact that I can’t find any tools to access the domain which don’t require the use of Eclipse (<sarcasm-alert>because, of course, everyone uses eclipse</sarcasm-alert>).

In any case, the script needs to be executed with a classpath referencing the hibernate jars, jython jars, your domain classes, and anything else hibernate & jython might need to access — I run it from within ant, but it could quite easily be executed from a shellscript.

I’ve just released v0.7 of my shopping cart plugin for WordPress. Notable inclusions in this release are automatic setup of product info (such as quantity and price), and the ability to have downloadable products — which is in the ‘experimental stage’ (see here for more information).

…for some reason it was really hard to see the monitor (see photo below).

in the office

:-)

My experiment with web templating is finally complete. You can see the resulting output of running this script against these templates (1, 2, 3, 4 and 5).

Yes, the code to inject content into the template is rather ugly, but that’s a byproduct of the fact that I’m hard coding these values rather than delivering them from a data model of some kind (and I’ve made no attempts to tidy up that code anyway).

The example below is particularly unattractive:

template['footer:col'] = template2.repeater(3)
template['footer:col:1:footer:heading'] = 'test1'
template['footer:col:1:footer:text'] = 'blah1 blah blah blah blah'
template['footer:col:2:footer:heading'] = 'test2'
template['footer:col:2:footer:text'] = 'blah2 blah blah blah blah'
template['footer:col:3:footer:heading'] = 'test3'
template['footer:col:3:footer:text'] = 'blah3 blah blah blah blah'

When a template fragment is imported into another, the IDs of elements in that fragment need to be prefixed (with the ID of the containing element) in order for all IDs in the resulting DOM to remain unique. When elements are repeated, they need to have a counter appended to their IDs, again to ensure uniqueness.
In this case, I’ve imported a fragment into a div with the ID “footer”, meaning that the elements inside are prefixed with “footer:” — then I use a repeater on a column element in the import. The algorithm which re-works the IDs isn’t particularly intelligent, hence the rather hideous 'footer:col:[x]:footer:[actual-id]' structures.

Read the rest of this entry »

Currently in source control for YAK (but not released yet), is the ability to automatically set price and quantity for all new posts — meaning one has to explicity remove the custom fields to stop a post being considered as a product. This is optional behaviour, of course.

Also added is default titles for products (picking up the post title, rather than having to explicity enter it). Which is one less custom field to enter.

I’ve had a couple of requests to support downloadable content. There are a few ways I could go about adding this feature — none of which are particularly straightforward. I don’t want to overly complicate the shopping cart, and a couple of methods would definitely result in overcomplication. At the moment my favoured approach would be when a user purchases downloadable content, an email is sent out with links for the downloads once payment is confirmed (either thru PayPal, or manually in the manage-orders screen). The link for the download would (potentially) be created using a combination of the product id, a uniquely generated id, and a passcode created specifically for the product… with the number of downloads allowed configurable from within YAK. This is perhaps not as user-friendly as providing download access from within the cart itself (i.e. payment confirmation redirects to a page which contains your download links) — but has the least (developmental) impact on the plugin.
I’d also like to add the ability to upload the content from within the plugin as well — but I think the initial version will just be via an .htpasswd/.htaccess secured directory.

So, comments welcome. Should this facility go into YAK now, or are there other features which you’d like to give a higher priority…?

For the benefits of Planet NZTech feed subscribers (like myself!), here’s a list of the posts missed since I migrated to a proper hosting provider:

  • Murphy’s Law example - a discovery that changing to a new host (that you’re actually paying for) results in a complete lack of time to do anything with it
  • python multicast - a comment I made on Tim Bray’s Java multicast posting (even better, I got a mention on his original post)
  • templating revisited - where I start to try to prove that I know what I’m talking about in regard to web templating, and that the JSF/facelets way of doing things is naff
  • templating continued - where I continue being a know-it-all, have given up on convincing anyone else, and have settled on just convincing myself that I’m not talking complete b*ll*cks.

END TRANSMISSION

I’ve done a little more work on ‘my’ approach to templating. One thing I’ve only mentioned in passing, is that there are other templating engines out there that work in this fashion — both in Python and Java. HTMLTemplate, is a python module I’ve already mentioned previously. Tapestry is a Java framework, which I haven’t personally used, but seem to recall uses an attribute language for its templates. And there are others, so what I’m experimenting with is hardly anything new. But I have yet to see one that I think goes far enough with the removal of markup from view components. Not to harp on about it too much (not half).

Read the rest of this entry »

I finally took an hour to revisit the templating code mentioned back here, using minidom instead of rparsexml. As expected, refactoring produces better code, but ‘better’ is a relative term — it’s still a major hack-job. However, in this case, I’m not bothered as long as it proves a point with as little effort as possible.

So, to recap my prior thoughts:

  1. I don’t like the complexity, and general inelegance, of the templates required to produce dynamic content with facelets & JSF. Faces on its own is bad enough; facelets (while admittedly helping to fix a lot of the nastiness inherent in JSF) adds its own ugliness factor.
  2. I don’t think it would be hard to design something better. Actually, let me rephrase that:

    An electric charge applied to a few single-celled organisms contained in a small bucket of slime could design something better.

My intention is, therefore, to hack together a quick prototype — hopefully coming up with something a little more elegant in the process. And since (I hope) I have a few brain cells to rub together, I might just provide reasonable competition to the bucket of slime.

Read the rest of this entry »

One of the problems developing with more than one language, is that the boundaries between them become a bit hazy at times. Case in point, this morning Tim Bray was talking about multicasting in Java, and wondered about the availability of similarly useful libraries in other languages (including Python). My immediate thought was (overconfidently), “Of course, it’s just as easy in Python…”

….only to realise that I was thinking about multicast in Java myself (and the last time I used that part of the API was at least 2 or 3 years ago). Now that I think about it, I don’t think I’ve ever tried multicast in Python. Nor standard datagrams. Haven’t had the need as yet.

But surely it’s easy right?

An hour or so later, and I have to admit, the Python documentation around the socket and SocketServer modules is really a little light on useful examples when you get into it. Setting up a simple server and client to talk to directly to each other (SOCK_STREAM) is easy. Figuring out what changes are necessary to talk via SOCK_DGRAM, isn’t immediately obvious from the module docs — thanks effbot for a working example.

After you get over that hurdle, you kind-of expect changing to multicast to be perhaps relatively straightforward. But that proves to be just as difficult.

The Python wiki saves the day. There are a couple of multicast examples there, but I could only get one of them to work, which I’ve adapted slightly below.
Read the rest of this entry »

No sooner have I set up a brand-spanking new site, than I am suddenly too busy to do anything with it. Not only that, but I also gave myself a challenge to come up with an example of something better than the butt-ugly facelets/JSF templating, and I’ve had no time to do anything much about that either. I have, however, decided that trying to hack together Amazon page would be a good test of the layout concepts, especially taking into consideration how busy the Amazon front page is. So I’ll document the process as I go… thinking aloud, so to speak.

I have hit one minor snag already. I’ve used rparsexml.py in my hacked together template engine (a piece of python code that will admittedly never win any code-elegance competitions), only to discover (RTFM) it dumps html comment blocks — which is perhaps only a pain if you happen to wrap your embedded styles in comments. So I haven’t entirely convinced myself that it’s not worth going back and revisiting the code with a better xml parser, motivation being in general short supply at the moment…

It seems as if the migration away from Blogger was successful, though I had a few hiccups that would probably have been easier if I’d planned things a little better.

Such as the fact that I temporarily staged my environment on my development machine, worked out the style and structure, imported all my posts from Blogger, only to then realise that everything would be associated with “localhost” rather than bluebear, when I copied the database over to the host. If I’d just taken the time to change my hosts file, that side of things might have been easier.

Still, I’m here now — and what’s more, it appears that the stylesheet works fine in Internet Explorer, despite the fact I completely forgot to test it first. Which is unheard of.

No offence to Rick, but I’m looking at the facelets examples in his article and thinking, this stuff just isn’t attractive. I’ve been involved in some reasonably complicated facelet+JSF pages recently — there is nothing elegant about the combination of html, JSF components and facelet tags, nor the amount of background effort required to get things working nicely. Still it’s better than the alternative — being solely stuck with JSF.

Which got me thinking. I understand the goals driving JSF; even agree with the reasoning behind (some of) them. Some portions of JSF are useful… but the templating side of things is generally hideous. Leaving me wondering why they couldn’t do considerably better? (Well I know one possible reason — Design By Committee).

JSF apologists will now be saying, “but you get a lot for free with JSF that you’d otherwise have to code”, to which I (inevitably) reply, “yes, but the free stuff doesn’t excuse the amount of crud one has to deal with.” There’s no really good reason why the useful bits (-some- of the lifecycle stuff, the automatic binding and so on) have to be bundled into an all-encompassing framework. Personally, I’d be happier with a cleaner templating system, and some libraries I can use (or not) tied together with a vanilla old-school servlet. And anyone who thinks they’re really getting added-value with faces’ navigations rules configuration need to hit themselves with a clue-stick.

One thing I’ve decided I do like from the templating side of JSF+facelets, is xhtml-based templates — something I never thought I’d be admitting. Velocity or Cheetah have traditionally been my templating engines of choice, mainly because I prefer a clean delineation between code and (x)html. Standard JSF+facelets doesn’t give -any- clean delineation, so you might be wondering why I’m contradicting myself — however I’ve grown to like the idea of xhtml which validates cleanly while still in template form, but I’m advocating going even further. Get rid of the additional tags altogether. Even more extreme than Tag Attribute Languages (ala Zope), something like HTMLTemplate would be a start, but even then that’s almost too much markup. You can’t get any more separation between view and model than if there’s no code in your view at all.

For example, it only took a couple of hours to knock up a basic python templating engine that would inject this:

<html>
<body>
<div id="banner">
    <p id="banner-heading">This is the banner heading which
will be internationalised.</p>
</div>

<div id="nav">
navigation goes here from an import
</div>

<div id="main">
    <div id="content">

        <table border="1">
            <tr id="datarow">
                <td id="datarow:elem:col1">the col1 property of an injected datarow object
will replace this </td>
                <td id="datarow:elem:col2">col2 will go here</td>
                <td id="datarow:elem:col3">col3 here</td>
                <td id="datarow:elem:col4">col5 here</td>
            </tr>
        </table>

        <select>
            <option id="sel" value=""></option>
         </select>
     </div>
</div>
</body>
</html>

with dynamic values, using the element IDs to lookup a context and try to intelligently decide how the element content should be repeated, imported and so on. From my point of view, the nice thing is it has no (non-html) markup, other than an arbitrary naming convention for repeated elements. Code goes in the controller, where it should be.

Okay, I haven’t convinced myself the concepts are completely sound — this is a damn basic template, and as soon as you want to do something complicated the whole thing will probably collapse in a steaming heap of badly hacked goo. But I have proven a couple of ideas to myself, and the basic xhtml above looks a darn sight prettier than the equivalent JSF+facelets xhtml would be. With vanilla xhtml, there’s no reason why the design-by-gui crowd can’t still have their drag-and-drop, all-bells-and-whistles, create-the-page-by-wizard development environment, and those of us who find it 10-times quicker to work from a text editor can still do so, without having to look at the ugly excuse for templating we’re now stuck with as a defacto standard in the Java web world.

[Note: either 1) code to follow once I've decided this sort of templating actually works for more complicated cases... or 2) an embarrassed silence after I discover I've forgotten something really important and the whole idea flops miserably]