religion.

12:00 PM me: Does [your company] use whitespace or tabs?

12:01 PM Ian: you mean spaces?

everyone uses spaces.

four spaces, in fact.

It’s Guido gospel.

me: But spaces suck.

12:02 PM Ian: not even remotely.

me: I know that’s the gospel, but it doesn’t make sense.

Ian: It makes excellent sense.

Easier to deal with. Only one kind of whitespace.

me: Do Windows and Linux use different tab characters?

Ian: no.

12:03 PM me: Dude, two-space tabs.

Google uses two-space whitespace, btw.

Ian: well, nobody else does.

me: I know. It drives me crazy.

12:04 PM

Ian: I like four. Everything lines up properly.


def myfunc():
____blah

me: Eh. I use two-space tabs in Ruby, and I don’t like to change when I program in Python. Gajim uses tabs, though.

Ian: We were never told this, it’s just the general rule.

12:05 PM me: Well, it’ll break if you mix them.

Ian: I am aware.

me: That’s retarded.

Ian: Not really. It has to break.

12:06 PM me: I know, but it’s still retarded.

12:07 PM

Ian: I mean, it’s been the standard forever. Tabs are bloody annoying, since they look like spaces but aren’t.

me: But tabs are semantic! Just turn on printer’s symbols if it bothers you.

12:08 PM What’s annoying is backspacing and it goes back…one…character…at...a..time.

12:10 PM I swear, future generation will look back on this as utter madness.


6 minutes

12:17 PM Ian: well. I don’t have to do that.

Vim does tht for me.

12:18 PM me: I thought so.

Ian: it backspaces a tab at a time if appropriate, otherwise space. It’s perfectly natural.

me: Well, that’s not so bad.

Ian: but my code will always render in exactly the same way on everyone’s machine. Lines will have the same length.

12:19 PM if it’s 79 chars, it won’t wrap on somebody else’s editor who has their tabs set to 8 or something

me: I’m right, though. But it is utter gibbering insanity.

What is sacred in web pages is verboten in code. This is ridiculous to me.

12:20 PM Ian: what is sacred in web pages?

whitespace is ignored.

me: Tab means indent!

Ian: tab doesn’t mean a damn thing in a web page

me: User sets the indent!

I know. Using space is like using <br /> in webpages.

12:21 PM You’re trying to control display.

And you call it a virtue.

Ian: well, yeah. html isn’t for content.

me: Madness.

Ian: indentation is set in CSS

me: Yes!

That’s my point.

12:22 PM Tab means <indent />

Ian: But it doesn’t.

In a web page, “beginning of paragraph” means <indent/>

12:23 PM there’s no tabbing.

You can’t artificially insert a tab character.

me: If someone said, don’t use <p>, use <br />, some users change the margins on paragraphs, you’d say he was an idiot.

Ian: You can’t double-tab.

no users change the margins on paragraphs. My own CSS does.

me: I understand. I’m saying tab means indent, a semantic element. It means level of scope in Python.

12:24 PM Ian: but it doesn’t. whitespace means level of scope.

me: But if they wanted to, they could. Then it wouldn’t display properly. Best to use <br />

Ian: no, they couldn’t.

me: Ahh!!!

12:25 PM Yes, they could. They could change the default stylesheet, and make it !important.

Ian: The end user doesn’t control the display of a web page, except for text size.

me: Ugh.

They have a degenerative sight disorder that requires the paragraphs to be widely spaced.

12:27 PM I’m saying the principle that is sacred in web pages is considered a liability in code, and only really in Python and shell scripts, because indentation is just for looks in C++, Ruby, Java, etc.

Ian: But no one will ever do that. I don’t understand how this is at all relevant. Code display has nothing to do with layout. The goal is to do it the same way as everybody else.

and that sacred principle is…?

i still don’t get it.

Since there are no tab characters in web pages.

12:28 PM me: Let the user determine presentation. That’s the principle. If they want to apply another stylesheet that makes your page look stupid, so be it.

Ian: But that isn’t a sacred principle in web pages.

me: Yes it is.

It’s why we don’t use tables and <br /> for everything. It’s why we don’t compose web pages in Word.

12:29 PM Ian: No, it isn’t.

We don’t do it that way because it’s extremely limited.

And it won’t display the way /we/ want it to.

me: Dude, wtf? Use flash if you want to control display.

12:30 PM Ian: But that’s totally wrong! That’s warped!

me: I understand that the user usually views a page the way you want him to.

But he doesn’t have to.

Ian: Always. Unless they’re hacking it.

In which case I don’t care.

12:31 PM Build the page to deal with big text and small viewports, but otherwise whatever.

me: What are you talking about? They can view a page in Lynx, or with a screen reader, or using a Greasemonkey script, or whatever.

12:32 PM

Ian: There aren’t other variations, except for the extreme outliers where people hack your CSS.

me: If it’s important to have code displayed with a certain size tab, you could include a hint at the top.

Ian: People using greasemonkey scripts know the page will be fucked up. Lynx doesn’t apply, since it strips CSS. Screen readers are a completely different thing.

12:33 PM me: I am horrified.

Ian: I dunno where you get this insane idea.

me: I don’t know why you’re fighting me on this. The whitespace thing, sure. But not this principle.

12:34 PM Ian: You can’t account for all users. Especially not if they are making up their own CSS.

me: <br />This is a paragraph.<br /> See, it’s better? Works every time, no matter what the user does.

Ian: It’s impossible to predict that.

Except you can’t do anything. That’s idiotic.

12:35 PM me: Yes, because it’s attempting to define display with markup.

Ian: but <p> tags aren’t for the benefit of the user

they are boxes with default CSS that you, the designer, change.

12:36 PM They’re roughly semantic, but you don’t use them wherever you have text.

me: Okay, I get you.

But a screen reader would use the paragraphs to know where to pause, for example.

Ian: They certainly don’t mean “paragraph,” and they’re only indented if you explicitly set text-indent.

If it’s a screen reader, you have a different style sheet

12:37 PM me: Yes!

Ian: and you use pause-before:blah

in the CSS

me: Do you define a css audio stylesheet for your pages?

Ian: Hell no.

me: So they use the default settings.

Ian: Certainly not for [my company].

12:38 PM me: It’s whatever they want.

And you can override stylesheet settings with !important.

Ian: Also it strips out all layout, so it’s irrelevant.

me: Huh? That’s layout. It doesn’t read them in any order.

12:39 PM Ian: WHO can?

The blind greasemonkey users?

me: Yes.

Ian: I will never, ever design a page for a blind greasemonkey user.

me: Argh.

Please see the analogy.

12:40 PM

Ian: I see what you’re getting at, but I think you’re totally wrong.

The user /can/ define presentation, but only by /breaking/ the original code and rewriting it.

Or using an application that discards certain things, like a screen reader.

me: “As god is my witness, I will never allow another programmer to view my code at anything but four spaces to an indent level. I would rather die.”

Ian: Or lynx.

12:41 PM So if you really want to, you can, before editing any code, translate all spaces into tabs, then do your editing, then retranslate and save.

That is roughly comparable.

It’s a simple greasemonkey script.

me: You’re saying it’s something freaky, because it’s rare. But it’s just rare. It’s something that’s built in to html.

12:42 PM

Ian: if you just have to have your indentation be a certain width, you can. But who the hell cares? The end user of code is the computer.

You make it useful for future coders, of course

me: You do know that all the CSS Zen Garden sheets refer to the same page, right?

Ian: Make it readable and whatnot

Yes.

It’s a basic HTML structure.

12:44 PM divs with some ps and uls

me: Anyways, I can’t change the whitespace to tabs. People would yell at me.

Ian: Well, then you change it back, before saving.

me: Whywhywhy?

Ian: Because code isn’t written for you.

It’s written for everyone.

12:45 PM I take that back: it isn’t written for anyone.

it’s written to be run.

You make it readable, not pretty

more to the point: you make it /editable/

12:46 PM (which web pages aren’t)

me: What’s so bad about tabs??? They only occur at the beginning of the line. If there’s one, it means one level of indent, two two levels, etc.

If the user chooses to view them at 4 spaces per tab, they display like that, if 2, then that.

12:47 PM

Ian: Nothing in particular, except it’s a whole nother character to deal with. If “whitespace=space” it’s easier.

From a coding perspective.

I don’t have to wonder if there are tabs anywhere, because they’re all spaces.

12:48 PM me: The thing is, it doesn’t even matter in Ruby! I can write the whole script without any beginning of line spaces at all! It’s only Python that cares! And Guido bases it on the C++ coding standard, where it also doesn’t matter!

Ian: If I want to indent only one space, I can.

If I want to line up my dictionary values, I can.

12:49 PM me: In Gedit, tabs are arrows and spaces are dots.

Ian: If you turn that shit on. But most people don’t. Most people use emacs and vim.

me: Well, okay, there’s something.

12:50 PMThings only get out of whack if you mix tabs and spaces, it’s true.

Ian: mostly it’s just annoying to have arrows and dots scattered throughout your code.

me: It makes it clear for me.

12:51 PM I don’t understand why “knowing if whitespace is a tab or a space” is more important than knowing that you haven’t accidentally backspaced and set a line to three space indent instead of four.

That happens all the time.

12:52 PM Ian: that never happens.

I have autoindentation on.

me: It’s happened to me. It’s happened in code that I’ve downloaded.

Ian: Then someone wrote it poorly.

12:53 PM That happened to me when I used gedit, which is a stupid application.

or notepad or something.

me: All this effort for a marginal problem of “knowing whether a character is a whitespace or tab” when it introduces another marginal problem.

Ian: But there are no problems.

12:54 PM My code is always clean, no matter who looks at it.

me: Just like there were no problems with the five year plans!

Umm.

12:55 PM Ian: Unless they have their line width set to something short. But then they would be an iiot.

idiot

me: Google uses two spaces! Four spaces is too much!

12:56 PM Ian: Google uses two spaces because fewer spaces translate into less downloaded.

me: Let the programmer decide!

Ian: Any web programmer worth his or her salt packs their code before uploading.

12:57 PM me: No, because code shouldn’t be nested beyond more than two or three levels anyway.

So it should be easy enough to read at two spaces.

Ian: ?

12:58 PM I mean, yeah, code rarely gets that deep

Except not really, when you have vars inside functions inside functions inside classes.

me: Most Ruby code uses two spaces and it’s easy to read.

12:59 PM About four or five levels.

Ian: Well, if Ruby takes over the world, perhaps other people will do it that way.

Idea

I just had an idea, similar to the Atmosphere concept (good picture here) from the My Dream App contest. It’s an added wrinkle, actually. Your desktop changes your wallpaper and window theme based on whether you’re at work or not. Yeah? Yeah? Yeah.

No, really. Just imagine it. It’s mainly neat for people who use the same system at home and for work. So you get up in the morning, and let’s say there’s a picture of a cup of coffee and a newspaper — with functioning news feeds. God, I’m a genius. Then it rolls around to the time when work starts. A cartoon work whistle blows. Suddenly your desktop resembles a cubicle wall, featuring a randomly selected Dilbert cartoon and a humorous or sentimental clipping of your own choice1. If you use MacOS2, the interface for all applications now looks like Windows 98. Access is restricted to all websites except www.howtobeabetteremployeetoyouremployer.com. Noon comes. A dialog appears, asking if you “brownbagged it today”, or if you want Rich down the hall to include you in his lunch run to Wendy’s. An old-fashioned TV with rabbit ears airs all the relevant clips from last night’s Dancing with the Stars for you to talk about in the lunch room. Okay, and then at 5:30, your desktop just goes crazy. It becomes a total disco inferno, with wacky strobing special effects and fake confetti and everything. Like, for a minute. And then it becomes this chill space jazz lounge, with cool relaxing music…

I sorted of pissed on this, but it might actually be cool to have your desktop bring up certain programs at different times of the day, and maybe use different configurations based on whether you’re in work-mode or not.

Update: I am a stupid idea god. This article says that Apple filed a patent for this. Ahem: “For example, the color gradation may be computed based on the time of day to mimic the changes in the colors of the sky.” This is kind of a bullshit thing to patent, btw.

  1. No, it doesn’t look like a physical desktop. That would be stupid. []
  2. or Ubuntu, yo. []

Using xsl to import a phpmyadmin xml file

Yep, following the last post I have to explain what I just did for the LazyWeb1 . This is going to be boring and technical, folks.

If you’re like me, you’ve exported a MySQL database as an xml file through PhpMyAdmin. In general, you shouldn’t do this. You want the SQL file. I don’t entirely understand it, but phpmyadmin does not import the format that it exports. If you throw away the database, you’ll be stuck with an xml file that can’t be easily imported. Okay, and if you already threw away the database? In my case, it’s an old Texpattern db that I want to get into a WordPress db, so if I can just get it into RSS form I’m home free. Here’s what you do:

  • Take a look at this explanation of XSL (XML Stylesheets).
  • Create an XSL stylesheet like this (name it stylesheet.xsl for this example):
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
    <title>Stupididea</title>
    <link>http://www.stupididea.com/</link>
    <description></description>
    <language>en-us</language>
    <xsl:for-each select="stupidid_text/textpattern">
    <item>
    <title><xsl:value-of select="Title"/></title>
    <link></link>
    <description><xsl:value-of select="Body_html"/></description>
    <dc:creator><xsl:value-of select="AuthorID"/></dc:creator>
    <dc:date><xsl:value-of select="Posted"/></dc:date>
    </item>
    </xsl:for-each>
    </channel>
    </rss>
    </xsl:template>
    </xsl:stylesheet>
  • Include a line like this at the top of the xml file you exported from phpmyadmin:
    <?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
  • Open an xsl-aware browser (most of them) and try to save the page as an rss file. Note: this was quirky for me. Sometimes the browser would just save the original file, sometimes it would save the stylesheeted output. Try with different browsers.
  • (WordPress) Import the RSS file after checking that it is valid.

This is the general solution for any case where you can recover your database by transforming the phpmyadmin xml into an importable format. You’ll have to play around with the options based on your use-case.

  1. Ironically, there doesn’t appear to be an entry on Wikipedia for Lazyweb. I understand it as asking on your blog for help with answering a question (“Dear Lazyweb, …”), i.e., you’re too lazy to research the topic yourself. I’m extending the concept of LazyWeb here to include the posts and forum threads that help you when you’re out googling for a solution to a problem. []

A minor victory.

For a long time now I’ve been somewhat of a GTD guy, although I’m not religious about it and I’ve never been quite able or willing to implement it fully. Basically, all this means is that I keep a todo list that I review when I’m feeling conscientious about my life1. One of the tasks that has been sitting in my list for a long time is Migrate old blog articles. Now I can cross it off! Look, I’m crossing it off: Migrate old blog articles. God, that was satisfying.

Yes, I finally managed to import all the posts from my old Textpattern blog2. These go back to the days when I was working at National Geographic in DC, and had a lot of free time during work hours to do fun things like investigate cmses and purchase web domains.3 Some of them are written in a half-ironic high philosophic tone, others are intended to express minimalist pathos.

This minor victory was achieved not without some casualties. I have a peculiar knack for smashing up virtual servers4 , clobbering databases and borking filesystems. So, uhh, I’m very sorry but we lost the old comments.

  1. Actually, I keep several todo lists, which is a big no-no in GTD. I use Tomboy on my laptop and stikkit.com when I’m at work. []
  2. Some of them reference pictures that I’ll have to dig up and upload. []
  3. That’s the origin of the name Stupid Idea. The original stupid idea was to create a website that would be a kind of clearing house for “stupid” ideas — ideas that were deeply flawed but worth preserving on and improving. There was a MediaWiki installation that held about 100 articles before I switched web hosts. []
  4. Try this on a Linux host that you have root access on: `sudo rm -rf /`. Note: please don’t. []

Memory

I have an intense memory of this show. I would have been six in 1987. I remember it as being extremely dark and disturbing. The protagonists wore power suits and the villains were completely robotic from the head down and they flew around in a post-apocalyptic industrial wasteland and fought. I think I must have had access to one of the toys at one point. There was a game you could play with the toy and a video cassette. I guess this game was stupid, or the toy broke or something, because I made my own “robotic soldier” out of a plush parrot and tinfoil, using syran wrap for the visor in the helmet. This augmented parrot was very, very cool and completely satisfied my feverish six-year-old imagination. My friend did the same thing with a teddy bear. Be sure to take a look at the wikipedia article. Who were the terrible people who made this show?

My City Story

a la The City:

I was listening to my ipod in the back of the bus on the way to work. A guy got on with a guitar and came and stood at the back of the bus. He hesitated, even though there were two available seats. He looked at me and said, “You know why a guitar is better than an ipod?” I shook my head and smiled ambivalently. He kept looking at me. I took off my headphones. “I said, you know why a guitar is better than an ipod? Because it’s infinite!”

Maybe he was trying to tell me this.

In Pittsburgh

Things that are different in Pittsburgh:

Alcohol — You can only buy wine or liquor at the state store. Only bars are allowed to sell takeaway beer … so the corner convenience store has an area where you can drink singles and smoke (smoking ban in effect March 30). You can bring your own beer or wine to a restaurant without a liquor license, and pay a corking fee. The way I remember it is, everything you can do in DC, like buy beer in a grocery store, you can’t do in Pittsburgh, and everything you can do in Pittsburgh, like drink beer in a convenience store or carry a six-pack out of a bar, you can’t do in DC.

Buses – Buses are part of the strangely influential and omnipresent Allegheny County Port Authority. Port Authority runs a huge transit system consisting of hundreds of little niche bus lines each with multiple permuations of [A, B, C, D…] and [Local, Express, Alternate], the T line light transit (which many people seem to feel is useless) and probably ferries, hot air balloons, etc. I don’t know exactly why I have this impression of bizarre complexity, except that it is a remarkably big system (facing cuts) that everyone takes for granted here. Near my apartment there is a dedicated bus road going downtown.

And buses have an authority beyond their size in this city. A bus I was on didn’t turn the corner at a sharp enough angle and couldn’t make its left turn because of the solid line of oncoming cars. The driver backed the cars up as far as they could go, and then forced three cars to drive onto the sidewalk before he could straighten out into his lane. The other day I saw a cop holding up traffic while he furiously berated a guy in a sports car for trying to get around a bus.

The buses aren’t actually lines, but cycles. They nearly all go downtown, so they’re basically named after their originating neighborhoods. These two facts confused me a lot when I first started riding. I couldn’t understand how I could get off the bus at one stop and then catch the same bus going in the same direction to go home. It’s because they follow a single route from the named neighborhood until they approach downtown, then they loop through the city and return to the single route when they get out from the city.

This is the reason for the (initially, to me) strange fare policy of having people pay when then get on if they are “inbound” and pay when they get off if they are “outbound”. Of course, it makes more sense for the bus to spend less time taking people on in the chronically congested downtown, especially at rush hour. But there are some places when the bus is still basically inbound but you’re planning to go outbound where it gets confusing. You just get on and don’t pay until you get off. Today I saw an angry homeless guy walk in through the back door (which is okay, as long as you’re outbound) and ride a couple of blocks and get off without paying. For all I know, it’s free to ride around downtown. At least, this is a fairly obvious hack of the system.

I think the bus system might be chainlinked way out into Allegheny county through a system of bus depots, like the one in nearby East Liberty. So the sense is that this is a commuter transit system where all roads lead to Pittsburgh’s downtown. 1 This is a city with lots of cool, fully-fleshed-out commercial neighborhoods, but everyone who rides the bus has a constant need to go downtown.

I know I sound out of it. It’s just so much more centralized than I’m used to living in DC, where the bus lines crisscross the city with the purpose of getting you from one neighborhood to another, or from one quadrant to another. Also, we have the subway2 . I would probably have a different view if I’d ever tried the daily commute from Maryland or Virginia.

Grocery store – We have a Whole Foods and a Trader Joe’s nearby. We mostly shop at the Giant Eagle, though. (Amy likes to free-associate this name with the divebombing bald eagle from the intro to the Colbert report.) The Giant Eagle in our neighborhood seems to be pursuing every demographic at once, and does a pretty good job of it. They have a complicated organization scheme that is oddly intuitive:

Cafe, plants, deli, gourmet cheeses, produce, deli breads… (yes, I’m doing this all from memory) then several aisles of food grouped by ethnicity: a whole wall of kosher foods facing miscellaneous European food nationality groups (e.g., German for jars of sauerkraut, a Scandinavian cluster for chocolates and strange pickled fruits) ; Mexican (e.g., salsas, including blatantly Anglo salsas) ; Asian (e.g., instant noodles) ; Italian (e.g., spaghetti sauce); Polish (e.g., pierogies) — each of these is very decently stocked with interesting stuff, and probably provides a good census of the ethnic-American makeup of the city. Along the walls, the standard fish, meat, milk, a small but vital fake lunch meats (and fake cheese) section, then pasteurized cheeses (remember the gourmet cheese section?) … over to breads, where you can find Thomas Squares Bagelbread3. Then several long aisles for: cookies, crackers, juice boxes; soups, spices, coffees and teas; beverages (juice); beverages (sodas); magazines; personal hygiene products; etc. ; etc. The two frozen food aisles feature lots of frozen ethnic foods, including more pierogies, as well as an excellent fake meat section (across and down from the Organic Foods section, which also has vegetarian fare). There’s a bank, a pharmacy and a place to buy bus passes. Amy gets a discount if she buys gas from a Giant Eagle affiliated gas station.

I want to talk more about this grocery store, I really do. The reason why I mentioned all that was to point out how ingeniously broken the store’s taxonomy is. In most grocery stores it’s more or less kingdom -> genera -> species, dairy -> cheese -> velveeta. Here, the categorization is based on clades.

Pretty good grocery store.

  1. If you ever study a map of the area between Washington, DC and Pittsburgh, you’ll see that all roads really do lead there, or rather through it. [back]
  2. I guess it’s harder to build a subway in a hilly city? [back]
  3. The humor of which will be explained in a subsequent entry. [back]

revelation.

[12:14:10 AM] tristil: All of a sudden, I get it.
[12:14:22 AM] Amy Taylor: yeah?

[12:14:26 AM] tristil: A rock group is typically four guys who practice a lot together.
[12:14:29 AM] tristil: To get a groove.
[12:14:54 AM] tristil: Jazz groups are a bit more fluid, because they’re trained to improvise and groove with each other.
[12:15:14 AM] tristil: Hip-hop is about a DJ and an MC or multiple MCs.
[12:15:36 AM] tristil: That’s why they have more collaborations.
[12:16:08 AM] tristil: Because it’s always a DJ looking for an MC, and vice versa. Each is incomplete without the other.
[12:17:42 AM] tristil: That’s all. I just didn’t know that before.

Update: Listen to this interview with Grandmaster Flash to gain true enlightenment. At the end he explains the origin of the MC. I love that: inward DJ, outward MC.

I am a programming god.

At least, I program. One of the happy recent developments in my life (out of some that have not been so happy) is that the programming thing is starting to come together.

What this really means is that if I apply myself to a programming task, usually in the form of hacking on an existing codebase from an established project, I am now able with considerable persistence and a fair amount of hair-pulling and alienation of my girlfriend, to push out a passable solution.

I can submit as evidence:

  • A patch (and follow-up patch) to enable Banshee support for the music track listener in Gajim.
  • The work I do as maintainer of the Alexandria1 project.

I find that progress in programming skill proceeds somewhat arithmetically. There are days that I have spent hours banging my head against a problem only to come up with a solution that consists of a single line change. So I’m doing better if I make one more significant line change than yesterday, two more, etc. I just wrote about 8-10 lines of code in the course of about 5 hours. Pretty good! This is the rate I maintain when hunting and fixing bugs. I do slightly better when I’m adding incremental features, in part because I’m busy introducing new bugs and because my own code tends to be verbose. There’s some backsliding in this metric when I figure out/remember how to be more concise (for example, using collect and writing blocks for functions in Ruby and using list comprehensions in Python2), but this a good thing.

The last step is to learn how to properly design a program from the ground up. Learning how to think OO3 is the last to come for me. Studying the Alexandria codebase has helped me a lot; the previous development team was a clever bunch of guys, full of meta-programming tricks and “expressive” Ruby code that have caused me endless hours of frustration and led me to some pleasing razor’s-edge-of-duress epiphanies. I’m working on a program called Chronology that will give me some practice with designing a program from scratch.

In another life, I got a CS degree and this is all easy for me.

  1. The current webpage sucks. To see what I do look here, here and here. I’m ‘method’. [back]
  2. But never lambda or map. Python, I hardly knew ye. [back]
  3. Object-Oriented Programming. [back]