Archive for the 'Programming' Category


Be a Forth DOER/MAKEr

2008-09-13 / 12:09 /

When I first looked at Forth I thought “neat, but where’s the virtual?” or how can old code call new code. Turns out that Leo Brodie’s Thinking in Forth has the answer: DOER/MAKE. Basically DOER creates a placeholder word and MAKE rebinds the definition. All via the magic of the explicitly controlled return stack.

Unfortunately this has the same drawback as C++’s virtual: dynamic code has to be explicitly declared.

In other Forth news

Looks like there’s a freeware version of VFX Forth available. Link via this Dr. Dobb’s article on Modern Forth.


Obligatory Chrome post… now with review!

2008-09-09 / 22:00 /

It’s official!

HTTP_USER_AGENT:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
  AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13

What’s to like

Most obviously: it’s fast. Javascript is super responsive; Gmail feels like a desktop app–unsurprising given Google’s design goals. The browser itself is pretty quick too. I didn’t bother running any half-assed benchmarks, but opening & switching tabs is noticeably faster than Firefox. (Which, as an aside, serves as a nice reminder that planning for performance isn’t the same as prematurely optimizing. Performance matters.)

Speaking of tabs, Google makes a big deal about Chrome being designed around the tab. I don’t really get much use out of the new-tab page but the ability to drag tabs out of a window is nice. Firefox let’s you drag tabs back and forth, but you have to manually create the window first. Firefox also doesn’t show you a cool thumbnail of the tab contents while dragging. Simple, but very useful.

The only time I open new windows manually is via Ctrl-Shift-N: incognito mode. I’m sure this will be useful for the politically repressed, but mostly I spend time on Persian Kitty.

Speaking of porn, looking at high-resolution web-design porn is nice thanks to the minimal interface. Despite the gimmicky sound of “we wanted to reduce the ‘Chrome’ of Google Chrome”
(link) there really is less clutter:

Chrome vs. Firefox screen real estate comparison

It’s also got some features that make browsing easier, like drag and drop file uploading and font scaling. The font scaling isn’t as good as Firefox: it doesn’t have the new Cairo-backed Firefox image rescaling so scaling distorts pages. Similarly Chrome’s drag and drop uploading can’t handle multiple files like dragdropupload (though, to be fair, that’s a plug-in). Last but not least, Chrome’s got resizeable text-areas. Amazing!

For the developers, Chrome’s view source has line numbers and live links that open in a new tab. It’s also got a built-in DOM inspector.

Oh, and, despite the pile of bugs it doesn’t crash.

Ok, what’s not to like

The missing functionality: ChatZilla, DownThemAll, Multiproxy Switch, Tabs Menu, etc.

The placement of new tabs can be a bit strange. Ctrl-T tabs go to the end. When clicking links from a tab, they open directly to the right of the current tab. If you click a bunch from the current tab, they open left to right. But something–not sure if it’s scrolling the page or changing focus or what–resets the order. So you open a bunch of tabs in order. Then a bunch more get prepended to that list. Definitely not a show-stopper.

And… the ugly?

Chrome is beautiful. It’s got the same well-designed simplicity of other Google products or anything from Apple (at least from what I’ve seen tangentially, I’ve got a $25 MP3 player, a Samsung cell phone and a Thinkpad). And it’s open source (WebKit plus Google’s own V8 javascript engine) so you don’t feel immoral using it.

But… but… it’s got no plugins.

A long time ago I was a devoted Opera user. I even paid for it! I didn’t switch to Firefox until there were plugins for better tab management and gestures. True, I could have flexed some open-source muscle and just changed Firefox’s source code…

Yeah, right.

Firefox managed to produce a tinkerer culture. Can Chrome do the same? Of course, I’m assuming a tinkerer culture is good. Maybe “closed & beautiful” is better.

Then there’s Ubiquity. If you missed the mini-buzz before Chrome stole it’s glory,Ubiquity is a Firefox plugin that let’s you script web tasks via Javascript scripting. It’s bookmarklets on steroids. Watch the video, it’s kind of awesome. I had more to say about it, but Mr. Jackson says it better.

Finally I’ve seen some comments about Chrome sniping Mozilla’s marketshare. I’m sure that’s a minority opinion, but it’s still a ridiculous one. Chrome is innovative. Putting that innovation in a brand new product instead of pushing it into Firefox is a design decision, not an attack. Time will tell if it was the right one.

In the meantime the release of Chrome has at least got people talking about the browser, which is a good thing and, incidently, one of Google’s goals.

Download it yourself

Oh yeah, I guess a link would be nice: Chrome

PS

I thought I’d try out a gratuitous use of highlighter to see if it makes the blog more scannable. Let me know!


My worst job ever

2008-08-06 / 17:17 /

Paul Graham doesn’t think you were meant to have a boss (and the Cliff’s notes in case you thought he was saying you suck). I don’t agree with the “lions and hunter-gather tribes didn’t have bosses” arguments–most hunter-gatherer’s weren’t very good programmers either–but I do agree that large companies are a bad place to work.

My worst job was a summer internship at FedEx. There were several superficial problems, mostly I was under 21 & car-less. Which is to say that I had nowhere to go and no way to get there. It was also the summer–in Memphis–so the heat and humidity were both in the (Americocentric) 90′s. And I had to wear khakis and polo shirts everyday. Normally I only wear polo shirts to weddings.

But the main problem was the job itself. Beyond a general choice (i.e. “technical, not business”), placement was up to the internship coordinators; I ended up in the group that fixed wide-area networking problems. There were no problems. Except for the occasional cable pull, I made network diagrams in Visio and read about 7-layer networking.

“Well,” you might say “that’s not because FedEx is big,” but you’d be wrong. Having free-time is a big company phenomenon. I’ve never been a founder, but I have trouble imaging them sitting around twiddling their thumbs. (I do have experience running one-time bike events and even something that small doesn’t leave much time for sitting.)

If you’re still not convinced it was a big company problem, the Network diagrams were needed for ISO certification. And I never saw the engineer I reported to use their computer for anything other than Solitaire–Windows Solitaire. Just try to imagine founders turning to each other and saying “I’m bored… why don’t I work on getting ISO certified?” “Great idea! You do that while I play some Solitaire.” (Sounds of mouse clicking. A single gun-shot comes from the direction of the angel investor)


I cloned the entire GHC repository and all I got was this 88 meg folder

2008-08-06 / 03:52 /

I’ve been thinking the next language I should learn is Haskell. Serendipitously, GHC switched to git.

git clone http://darcs.haskell.org/ghc.git


nose.runmodule()

2008-08-05 / 23:25 /

This took more than 5 google minutes, so maybe it’s worth sharing.

You can make nose run the same way as unittest’s main by using nose.runmodule().

In gratuitous detail:

import nose

def test_foo():
    assert True

if __name__ == '__main__':
    nose.runmodule()

Using nose.run() activates nose’s test discovery. Test discovery is pretty useful for running a bunch of tests, but rumodule() allows for the snappy (ultra-snappy, thanks to Gary Bishop) C-c C-c in python-mode.


Me and MeshU up in Toronto

2008-06-03 / 07:22 /

Avi’s blog post reminded me that I never summarized my trip to MeshU. In a word: good.

Or in several words…

Prelude

I left Pittsburgh in a shiny new rented Sebring and drove to Toronto in about 5 and a half hours. The only events of interest were 1) realizing I had no washer fluid and 2) a small delay at the Peace Bridge for Victoria Day.

Tron I got parked ($10 CDN/night) and checked in to the Neill-Wycik, which exceeded it’s Hostels.com reviews. The room was a dorm single in a suite, though the other rooms seemed empty. I only saw one other person and only for the 2 seconds it took her to go from her room to the bathroom.

The roof offered some Victoria Day firework watching, unfortunately underwhelming compared to the Zambelli’s work. Then back to the room & free Wi-Fi to check if the post-conference weather would be good for camping. Not only was the weather looking dodgy, but I had forgotten my AC Adapter.

Tuesday morning

If I had to come up with a complaint of the Neill-Wycik, it would be the inability of the curtains to stop sharp rays of sunlight from stabbing me in the eyes. I woke up right around sunrise and spent some time reading Black Dogs. I considered showering, but since the plan was to drive straight from the conference to Tobermory and sleep in the car, it didn’t seem worth it. Plus I didn’t shave or bring business cards so I figured professionalism was right out the window. They’re lucky I wore pants.

Neill-Wycik disposes of trash proper Before going I checked all the drawers to make sure I didn’t forget anything. I’m not sure if it’s official Neill-Wycik policy, but there was a random porn DVD in a desk drawer. Feeling that this was the ultimate souvenier, I took it. This comes up later in the story.

I walked the few blocks to the MaRS center. The sign-in and breakfast (fruit & carbs) was in an open area immediately adjacent to the conference rooms. I found a table and “networked.” It was an interesting mix of designers, technical-ers, and entrepreneurs. They did a quick and–from where I was sitting–unintelligible intro and then we were off.

Beyond relational

I decided to see Avi Bryant’s “Beyond Relational Storage” talk based on the strength of his blog and Seaside.

I wasn’t disappointed: his talk was awesome (my notes).

He covered a bunch of alternate data storage strategies (SimpleDB, in memory, Prevayler, etc.), took questions, and then gave us a sneak-peak of MagLev (which has blown-up the blog world since it’s official debut at RailsConf).

Aftwerwards there was a small talk at my table. My neighbor was Markus, the CEO of Palomino System Innovations. They make a CMS, but mostly I was interested in their custom XML store.

Interlude

I was planning on running to Best Buy over break, but my laptop seemed to be doing ok in real ultimate power-saving mode so instead I made some calls.

Thorncrest Outfitters strongly–as in “we won’t rent you a kayak”–spoke against my proposed paddle to Flowerpot Island in Five Fathoms Marine Park. They proposed a one-day river kayaking trip, which sounded far less exciting.

Blue Heron affirmed that they take campers to Flowerpot Island but warned that the boat might be canceled since the weather called for rain and high winds.

Designing

Iterative Design Strategies w/ Daniel Burka One of the breakfast webbies, Angie (I think, I didn’t get a business card) was excited about Daniel Burka‘s “Iterative Design Strategies” talk (notes) so I thought I’d check it out. I had planned to go see Reg’s talk, but, while neither designer or manager, I’m closer to designer. Or at least I occasionally make a user interface that isn’t a command line.

Daniel’s talk was “I sat on the floor” crowded. I liked his case study of his redesign of the Digg comment UI, but otherwise I wasn’t the right audience. It was basically Agile for designers. A good idea, but not something I need. It is however the only talk I took a picture of.

Lunchtime networking

Lunch was notable for the company. I sat with some current/recently matriculated students: Julie, Andrey, Andrew & uhm… the tall woman with the blond hair whose name I have forgotten. Pete Forde from Unspace was also there facilitating the conversation and unashamedly flogging Ruby Fringe, which sounds interesting but is too expensive for me & too non-work related for my employer.

Implementing OAuth

My third session was Leah Culver’s “Implementing OAuth” (notes). Leah started with a review of OAuth (and the difference from OpenID), explained the protocol & showed the code. A fairly good talk, though again not directly related to me.

Some of the questions coming from the front seemed strangely pointed… perhaps beacuse they were being asked by Cal Henderson. The old “plant in the audience” trick. Very clever, Leah and Cal, very clever…

And finally, Mr. John Resig

Despite the rumors that John Resig’s jQuery talk (notes) was going to be introductory, I wanted to see him talk. Plus I’ve never used jQuery, so I was ready for an introduction.

Before the talk John got some water from our table (near the front). I talked to him briefly about processing.js, which I’ve been meaning to look at for online plotting.

His talk was a quick introduction to jQuery followed by some live examples of unobtrusive prototyping against live pages. jQuery looks as good as its reputation, I’ll be trying it out whenever I have a chance / excuse.

The end of the day

I kind of wanted to go to the afterparty so I could tell Avi I liked his talk. He was busy at lunch and the only other time I saw him was at the urinal, which seemed like an awkward time. I also wanted to make up for my lack of pictures by getting photos of all the presenters giving me bunny ears. Alas it turns out the after-party was a significant distance away. Instead, I tagged along with Julie, Andrew & Andrey for some pan-asian dinner at Spring Roll.

Dinner & conversation were both good.

Then I walked back to the car.

The drive north south

Google Map directions took me North on Spadina, which seemed more than a little suspicious. Eventually I turned around got on the Gardiner Expressway. It was about 7:30 and it would take another 3 hours to get to Tobermory where I may or may not get to ride a boat to Flowerpot Island. Given the chances & the weather I just took Gardiner to the QEW and headed south.

I stopped at a Tim Horton’s to pee and pick up a tea. I figured I’d need the caffeine later.

I stopped a second time at the US border crossing.

The border guard asked me a bunch of questions. He seemed especially interested in the fact that I was only in Canada for a day. Then he confiscated my contraband oranges and bumped me to 2nd level border check. I parked in the directed spot and went inside. Some border agents checked my license and passport and asked more questions. Then they went to search the car.

I was sitting in the waiting room when I realized I had a mystery porn in the trunk. I ran through a few nightmare scenarios where it was actually child porn or something. Who would believe I found it in a drawer in a hostel? Luckily the agents came back in and told me I was free to go.

The agent didn’t have a solid reason on why I was stopped. It was probably because I spent a single day in Canada and was crossing the border at night, but I was hoping it was something like “the agent saw your trunk full of perversion.” That would at least give me a funny story. As it is I was just left with a dull feeling of violation and powerlessness. How Kafkaesque.

I gave the DVD to Casey. It’s a Japanese porn. Nothing special, and certainly not worth the stress.

Final words

I suppose I should wrap up something about the conference and how good it was to meet new and interesting people. But really, my advice is to just leave porn in drawers.


WTFOTD: Microsoft, shared drives, properties

2008-05-27 / 12:03 /

  1. Have an external drive with mounted to S:
  2. Have a network share mounted as S:
  3. Open Disk Management
  4. Right click the external drive and select “Properties”
  5. Be surprised when the properties for the network share come up

It looks like Microsoft looks up properties via drive letter, even when you physically click the drive in the Disk Management app. Not deadly, just surprising. Maybe this should only be a WTHeck?


On Java One and shark jumping

2008-05-08 / 12:29 /

After reading Tim Bray’s description of Java One, I’m even more un-interested in Java (which is not to say anything bad about Mr. Bray himself). Call me cynical, but when a company spends that much money to generate hype… well, shouldn’t people just use an environment because it works? Or do all languages do this? Have I been missing the annual C extravaganza?

Anyway, yet another sign. If it weren’t for Clojure I’d uninstall the JDK altogether.

In related conference news, I’ll be at MeshU 2008 in two weeks; hopefully followed by a stop at Five Fathoms.


Ah-hah! Of course recursion can create a dependence on the global namespace!

2008-04-29 / 16:44 /

This works because there is a global variable, fact, that has its value set to the value of the lambda expression. When the variable fact in the body of the function is evaluated to determine which function to invoke, the value is found in the global variable. In some sense using a global variable as a function name is unpleasant because it relies on a global and hence a vulnerable resource—the global variable space.

Richard Gabriel, The Why of Y [PDF]

(emphasis added)

On reflection, “normal” recursion relying on the global namespace is obvious. So are the potential problems:

> (define fact (lambda (n) (if (< n 2) 1 (* n (fact (- n 1))))))
> (map fact '(0 1 2 3 4))
(1 1 2 6 24)
> (define fact2 fact)
> (map fact2 '(0 1 2 3 4))
(1 1 2 6 24)
> (set! fact (lambda (n) 1000))
> (map fact '(0 1 2 3 4))
(1000 1000 1000 1000 1000)
> (map fact2 '(0 1 2 3 4))
(1 1 2000 3000 4000)
>

Never really thought of it that way before.

That’s not the main point of the paper, of course. It’s really about the derivation of the oft-asked-about Y-Combinator.


Information economics

2008-04-11 / 16:01 /

(Here’s one from the vaults: I started writing this July 2007)

I like Reg, so I was surprised when I thought he wanted comments on his site instead of aggregators.

It turns out I misinterpreted his post. He responded to my comment:

…But yes, I do think comments on reddit and most especially links in social bookmarking sites break the web by placing them in someone’s proprietary database, instead of on the web itself…

But what happens if del.icio.us publishes a new EULA and shuts their API down? Suddenly, it’s as if all the links, all the intelligence, was locked in a box.

With “bloggers,” each individual has a lot of power over a very small part of the web, but no one entity has a lot of power over a lot of the web.

Social bookmarking sites concentrate that value in a few hands. You may not trust me. But you can trust bloggers in aggregate, and the web as a whole.

<3ing on Walmart

As long as marketing and advertising fund the web, information will be the currency (well, “attention” I guess, but information is the attractor). In an information economy, Reg is arguing against Walmart: why support a censor-loving union-busting monarchy instead of that quaint local shop?

Altruism is great, but sometimes Walmart is just easier. Gabe da Silveira nails it:

Regarding the concentration of power, that’s just an economic requirement. Most users can’t create their own websites, or run their own servers, much less write their own software.

Even if you can create your own website there are benefits to scale, not the least of which is PageRank. And used properly, an aggregator can raise all ships: the author reaches a wider audience, commenters get single sign-on and response tracking, and reddit gets content for their hungry eyeballs.

A third way

Unlike money, information is inexhaustible. Less pretentiously: why not copy the reddit comments onto your own site? Simply 1) query reddit for your stories URL 2) if found, screen-scrape comments and 3) add them to your own blog. Realistically: reddit has no API (despite the request), the HTML isn’t easily scrapable and, of course, there could–IANAL–be legal concerns.

But not all site are the same: del.icio.us and digg both have API’s and Flickr has made switching services easier by granting API keys to its competitors.

Reg points out that an API can be nullified with the flick of an EULA. A site could also disable their API or start blocking IP’s, but it’s unlikely. Economics cuts both ways: large sites grow larger by using their scale to provide value; large sites become small sites by pissing off their customers. The easiest way to piss customers is by having an inferior product. Open data isn’t as important to most people, but it will be once enough people get burned.

Interoperability is important to a specific group, namely developers. Check the furor over AppEngine. The business case for an API is that a thriving ecosystem provides the best sort of lock-in: happy customers. If restrictive policies drive away the builders of said ecosystem, why bother having an API at all? (Counterpoint: the internet swelled over the idea of coding to a closed platform. I wonder what will happen when Android phones show up?)

A monopoly would change everything. This is both worrying and… er, not worrying: closed data could be the new lock-in or maybe the internet’s low barrier to entry will keep facilitating innovation (and in turn defection).

Vote with your bits

If you care about open data there are several things you can do. In roughly descending order of difficulty: pass an open-data law, write data liberation programs (like the reddit comment-crawler) or use the meme-sharing power of the internet to organize (see: Creative Labs).

Those all require skill, or at least initiative. At the bottom of the hierarchy is the simplest: vote with your bits. In this light, Reg’s post (and those of the EFF, Larry Lessig, Cory Doctorow, Mark Pilgrim and others) form like Voltron into a digital Ralph Nader, educating the online community so we can all invest our information wisely.


Are your comments getting borked?

2008-04-11 / 14:58 /

Rob tried to comment got both a rejection by WP-IDS and a nice PHP error message about missing paths. Woo boy.

The error was probably caused by a configuration error that I think I fixed. But I’ve got no idea why the comment was rejected in the first place.

If the same thing happens to me let me know and I’ll try to fix things.


TDD skips the idea phase

2008-04-11 / 14:53 /

One of the parts I liked about The Myths of Innovation (full review) was the simple description of brainstorming:

  1. Facts
  2. Ideas
  3. Solutions

I’ve previously had some issues with TDD, and viewed in Scott’s three steps I realize it’s simply: TDD skips the idea phase.

The facts are the problem you’re trying to solve, and the solution is the end product. I guess the ideas are supposed to be the the tests & code, but that just doesn’t work for me. Maybe I need nimbler fingers but I suspect that the real problem is that code is too limiting. By nature, programming distills an abstract idea into instructions so simple that even the world’s fastest idiot–a computer–can understand them. This clear, orderly expression of ideas is too limiting for the free association that generates new ideas.

Or maybe it means that I’m not yet fluent in my language (Python) or the underlying language of programming (architectural decisions, algorithm complexity, etc.)? Perhaps being a master programming is a fluency such that it’s faster to sketch in Emacs than on paper; familiarity has certainly cut down on my need for crutches. Master level fluency also explains both the talented programmer’s obsessive devotion to their chosen language/environment and love of learning new languages. The first aids expression, like an artists well-lit studio or a gamer’s abbreviations and slang. The second expands the range of expression, like an artist trying a new medium or a gamer going outside.

But if expressing ideas in TDD requires fluency, then its purest “test&code” implementation is only useful for master level programmers. Is this an example of how agile is only for elites? (more “agile only works for elites” links welcome, I know there are more but couldn’t find them)


So what PHP security hole did that open up?

2008-04-11 / 01:56 /

To make playing around with WordPress easier, I wanted to set-up a local test environment. Since Tim Altman has renewed my quest to get PHP authentication working on DreamHost, I need to run PHP via CGI.

Whew-ee.

The PHP Windows installer added some lines to httpd.conf:

ScriptAlias /php/ "c:/php/"
Action application/x-httpd-php "/php/php-cgi.exe"

After installation I could only run .php files from cgi-bin/ and only by using #!. The PHP install.txt lead me to add

AddType application/x-httpd-php .php

Which didn’t help. Luckily Apache’s logs/error.log sensibly stated

...[error] [client 127.0.0.1] client denied by server configuration: C:/php/

So now I’ve got:

<Directory "C:/php/">
    AllowOverride None
    Options None
    Order deny,allow
    Allow from all
</Directory>
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"

Which works, but at the expense of allowing access to the C:/php directory. What kind of security holes does that open? I poked around in the browser and couldn’t access any of the files. Plus the Apache user also doesn’t have write access to the directory and I only start httpd right before testing. Still…

White hats: advice, please.

Black hats: mercy, please.


Scott Berkun: writes ok, talks real good

2008-04-01 / 13:54 /

Scott Berkun talking at CMUNot only was I lucky enough to see Scott Berkun on his recent trip to Pittsburgh (easter egg: can you find me in the–blatantly hotlinked–picture?), I got there early enough to get a free copy of his book.

The book is ok.

It’s easy to read, well researched and visually beautiful. Beyond that, I didn’t get that much out of it. Many of the lessons–innovation is the result of hard work, you seldom know what you’ll end up with, bad ideas sometimes win, human skills are important, etc.–are things I’ve already internalized. The description of the steps of brainstorming–facts, ideas, solutions–and the role of soft skills stimulated some ideas on agile development and management, respectively (more on those in another post).

The writing is entertaining enough: Berkun’s style is casual and the stories are well integrated. His sense of humor runs a little more Dave Barry–aka non sequitur–than I prefer. YMMV.

According to the dust jacket and amazon my views are in the minority. I suspect this is due to 1) the audience and 2) Juno scoring.

As a 101, the book works well. It might also be useful for those from the “traditional management” or “wait for a lightning strike” school of innovation. I’m neither of these, though I can think of a few people who would benefit from a copy.

I suspect some people review the book like Juno: it’s not deep, but who cares? It’s entertaining. It’s far from onerous: at 150 pages and with a tone like listening to your well-read friend chat, the book is easily read in a day. And the “anyone can innovate, you just have to go out there and try!” message doesn’t hurt either.

This isn’t to discount these reviews or people who liked the book. As with the humor, YMMV.

Anyway, I’m glad I read the book, but it’s probably not one that will live on my bookshelf. That’s strictly reserved for books that make me look real smart.

But as a speaker…

…Berkun is very good. He is energetic and entertaining. He interacts with the audience. He knows what the hell he’s talking about. The ideas–as in the book–aren’t terribly deep, but hey, it’s an hour long talks. If you want entertaining and deep you’re basically limited to Simon Peyton Jones. He also had about 40 minutes of Q&A which provided some of the best take-aways.

Recommended.


Fixing a glitch in wp-validator

2008-03-16 / 23:17 /

After a missing </span> tag shrunk my sidebar text to an unreadable size (in IE only, which meant I didn’t realize it for a few days), I installed Rudd-O’s wp-validator WordPress plugin. It’s a pretty nice plug-in: it validates your post when saving and pops-up a message on the editing page.

There are a few catches. It relies on xmllint and/or tidy, so those have to be installed on your hosting provider (mine has tidy). The bulk mode (check all existing posts) said my posts were all fine, which turned out not to be true when editing some of them by hand. And finally, some posts refused to open for editing: the page would just keep on loading.

The PHP opens tidy as a sub-process and pipes in the post content. I started looking for a time-out option in proc_open but then saw this comment. Adding stream_set_blocking($pipes[2], 0); seemed to solve the problem. I tested by opening one of the posts that formerly hung. I then triggered an xhtml error by inserting a literal &, so the change doesn’t disable checking.

Unfortunately I don’t completely understand why the code is blocking. I ran both a hanging and a successful post through tidy in the command shell and they ran fine. Since I didn’t understand what exactly was happening, I only added the change to the tidy section and not to the function that runs xmllint.

Anyway, here’s the patch and the complete file (right click and “save-as”, if you click you’ll get a PHP error).


Meta: category clean-up

2008-03-16 / 17:59 /

Since WordPress 2.3 added support for tags, I’ve moved my old categories to tags and created some new ones:

Cycling
Info about bikes
LOTD
Link of the day
Misc
Everything else
Music
Chunes
Programming
Computer related

Categories will be stable and let you filter down to the posts you care about. So if you find yourself saying “cygwho?”, maybe Programming isn’t for you.

The plan is to add some display of tags later. But man, tag clouds sure are ugly.

Implementation

Moving the categories around wasn’t too bad using the built-in cat2tag and Rob Miller’s Batch Categories plugin.


Cygwin quickie: opening files with cygstart.exe

2008-03-11 / 10:23 /

Cygwin‘s cygstart.exe is amazing. It opens data files as though you clicked on them in Windows Explorer. Best of all this including folders: cygstart mydir opens up a view of the directory. I’ve got mine aliased (actually a symbolic link so I can use it from eshell) to op. I started off with it aliased to open but I used it enough that the 2 keystrokes were worth it.

$ ln -s /usr/bin/cygstart.exe ~/bin/op

Meta update: no more LOTD on the front page

2008-03-10 / 06:12 /

Are you tired of all the damn LOTD posts? Well, fret no more gentle readers, so am I. Not tired enough to stop writing them, just tired enough to move them off the front page. LOTD posts will no longer show up on the front page or in the main Atom feed. You can instead find them here:

I’ll update the front page later to make the links obvious.

How’d you do it?

I used WordPress’s query_posts command to filter the “lotd” category out of the main page. This required is_home on the HTML and some messing with categories in the Atom feed.

index.php:

<!-- Remove LOTD, also in wp-includes -->
<?php
   if (is_home()) {
      query_posts("cat=-7");
   }
?>
<!-- elided -->
      <?php while (have_posts()) : the_post(); ?>

feed-atom.php:

    <?php
      if (!$cat) {
        query_posts("cat=-7");
      }
    ?>
	<?php while (have_posts()) : the_post(); ?>

Alternates

Reg uses del.icio.us. That’s probably a better way. One of the benefits of LOTD posts are that I often go back and use them as references. Why not just store them in a link aggregator with an appropriate tag (e.g. “ref”)? I’ll play with the current system for awhile and see how it feels.


Tables are the new black?

2008-03-07 / 18:01 /

In early January, Zed Shaw redesigned his site with tables (but where are the links from the main page to the individual posts? Makes linking a bit un-fun). Now Kevin Yank says Table-Based Layout Is The Next Big Thing.

Some of the early comments on Yank’s article seem to be, as Zed might say, lemmings following that “Zen CSS bullshit”: they fault Yank’s example for being non-semantic. But if you check out his source, it looks like any other sexy mark-up:

  <body>
    <div id="header">
      <h1>Page header</h1>
      <p id="skipto">

That’s just a snippet, but you get the idea. No <table> to be seen. Instead, he uses (exceptionally simple) CSS to get it to render like a table.

On the other hand, Zed’s entire page is one giant table:

  <table id="fuckyourcssbitches" cellspacing="0" cellpadding="0">
    <tr>
      <td id="leftcolumn" valign="top" rowspan="2">

“Oh no” you think “a table!” But the markup is semantic; check the id="leftcolumn" attribute on the <td>. If you can’t figure out what that column represents, well… the problem is probably not the HTML. (and if you can’t figure out his view on CSS based on the id of the table…)

There is one problem with a table layout, though: adding actual tables. Putting an id on your main “page layout” table allows you to do special styling. This is what Zed does in his css:

#fuckyourcssbitches {
 padding: 0px;
 margin: 0px;
 border-spacing: 0px;
 width: 100%;
}

But what if you want to style an actual table of data? If you don’t write your CSS selector write, you’ll end up with your table styling affecting everything on your page.

On the other hand, using an HTML table has one huge advantage over Yank’s CSS table: it works. Yank’s article is specifically about how this will be viable once we get to IE8. 8. Doh!

What to do, what to do

If you want working HTML-tale-less layout now, you can do a few things: 1) Use one of the many tutorials or 2) use Blueprint CSS. Blueprint makes it easy to “design to the grid” (where “grid” is basically a designers word for “table”). You just have to include blueprint’s CSS file and add some classes to your source.

As I said before, the one problem I have with Blueprint is that, like using HTML tables, it injects some style information into your HTML. You have to add things like class="column span-20 last" in your markup. I’ve read some debate back and forth over whether this is a problem or not, but as a user of Blueprint I can say that it is for me. If I change a column position I have to change markup on every similarly formatted page. This kind of skips the whole beauty of changing a single CSS file and having everything change consistently.

Anyway, I’m using Blueprint and probably won’t change anytime soon. I am impressed with Yank’s CSS table layout–it’s just so simple–but given that it doesn’t work in IE it’s pretty much a non-starter. If anything, this points out the failings of CSS and browser implementations in general. Let’s hope CSS 3 and future browsers improve things.


Getting things done with Agile and pens

2008-03-07 / 16:42 /

Maybe when pair programming works it works because when you schedule a pair programming session with your buddy, you force each other to get started.

Joel Spolsky Fire And Motion

Agile is all about

  1. Just get started
  2. Build for change

Joel says pair programming encourages the former. Test driven development is about the latter: unit tests make it easier to change your code in the future. If you always write tests first, you’ll have 100% coverage. Since you’re writing tests first, you’re also designing the interface you’d like to use. Finally, since you want to test components in isolation, TDD promotes loosely coupled code.

Brilliant! Well, when it works.

For awhile I was doing (fairly) strict TDD. I’d immediately write a test, watch it fail, then code until it passed. But sometimes, 2 hours later, I’d be down a rat hole. I’d coded myself into an interface dead end; all I could do was back up, burning the trusses on the way out. Occasionally I’d find that I’d gone down a rat hole in another house and was solving the completely wrong problem. Or, worst of all, that there was no problem in the first place. Like I was standing right next to a solution but said “Hey, let me go dig some holes in the basement of that haunted house in the middle of the ghetto! What could go wrong?” (answer: lots)

Clearly something was not working. So I grabbed a new tool: a pen.

Now I start out with a pad of paper covered with notes and arrows, sort of a verbose mind map. Writing things down organizes my thoughts so that I start coding with a clear idea of what the final code will look like. It changes along the way, of course, but I don’t have so many “oh shit” moments.

2 types of agile

I’m not saying you should go get make yourself a nice shiny pen, just that it worked for me. This is agile, or at least the small ‘a’ kind. I still think big ‘A’ Agile is the best methodology going, but only if you avoid getting ideological.

In other words, feel free to abandon “Agile”… but “agile” is forever.

(Just to be clear, this distinction has been pointed out by many people in many places, I just don’t have links.)