Archive for September, 2004

Why does this site look like crap in my browser?

Thursday, September 30th, 2004

Either because your browser sucks because you’ve been lazy and haven’t upgraded to a better browser yet, or you have bad artistic taste. I’ve designed this site the way I want to, and I’ve even been nice about making it look the way I intended in the majority of Internet browsers out there (I’m looking at you, IE). That said, I didn’t test the site in old browsers because no one should use them; they’re old, buggy, and inferior in every way to modern GUI browsers.

I suggest that you go get this better browser immediately if you don’t already have it.

For the record, I’m also going to point out that whenever the site design changes, I’m very moody about testing in browsers that I don’t use. This means that if you’re using an obscure browser, or a dead browser, there may be problems with the site that I’ll never know about because they are caused by your browser rather than my code. The major exception, of course, is Internet Explorer 6 for Windows, which I never use but do test in. Even there, however, there may be problems that will take some time to resolve, so as long as things are generally readable, I’m not going to worry about it too much.

As I said previously, you really should be using a better browser by now, anyway.

What’s the Proper Spelling of Bipolar Disorder?

Thursday, September 30th, 2004

The words “bipolar” and “disorder” are just words. Sometimes I capitalize them and sometimes I don’t. I haven’t yet found any definitive text which seems to care, so I don’t really care either. Usually, I won’t capitalize them because that means a little less typing for me.

In general, you can consider the following variations of the phrase equally valid in any circumstance:

  • Bipolar Disorder (with initial capitalization).
  • BiPolar Disorder (with camel-case-like capitalization; the “b” and “p” of bipolar are capitalized, as is the “d” of disorder).
  • bipolar disorder (no capitalization)

What are hot (or “access”) keys?

Thursday, September 30th, 2004

If you’re using a modern browser, then you’ve seen the text “Hot Key:” in links on my site, such as the navigation bar. For instance, the hot key to load this page is 6.

Hot keys are, very simply, keyboard keys you can push to navigate through a site without using a mouse.

  • If you’re on a Macintosh computer, simply press command and a hot key to follow the link associated with the hot key.
  • On a Windows-based computer, press alt plus a hot key to focus on the link, then press enter or return to follow it.

You can find out more about hot keys in my Accessibility Statement (when I write it up).

Unix Geekery for Line Edits

Wednesday, September 29th, 2004

The other day I found myself with a chat transcript about email security and I wanted to put it online in my other blog. Unfortunately, in order to do it properly I needed to add <p> to the beginning of each line and </p> to the end.

As I started manually adding the proper HTML paragraph markup to the lines I realized that what I was doing was pretty stupid. There are a number of ways to automate these simple changes to a file. Usually this can be done via a simple find-and-replace function of good text editors. In this case however, I didn’t want to replace anything, and while I could run a find-and-replace on line-endings (aka newlines) and then replace them with a line-ending followed by <p>, I didn’t know how to match line-endings in the program I was using (which was notepad2).

Then I realized that I already had access to the perfect utility to perform such a function, and one that could find anything I wanted in a file, including line-endings: sed. Sed is the Unix Stream Editor, and I had been meaning to learn how to use it for some time. Finally, I had the perfect excuse to read a sed tutorial! Combined with some input and output redirection, I executed the following command in my shell:

cat chat.txt | sed -e 's/^/<p>/' -e 's/$/<\/p>/' > chat-sedified.txt

Here’s what happened:

  1. First, the chat.txt file was printed on STDOUT, but instead of just displaying that output I piped it into sed with the | (the vertical bar, or, incidentally, pipe symbol). In other words, the output of cat chat.txt was turned into the input for sed.

    Now that sed was given input, I told it to run two expressions (using the -e flag or option) one after the other.

    1. The first expression runs a search-and-replace (the s in the expression), looking for the beginning of the line (the ^ or caret character) and inserting an HTML paragraph mark (<p>, obviously).

    2. The second expression does the same thing, only for the end of the line instead of the beginning. ($ matches the end of the line.) There is only one complication: sed’s search-and-replace uses the forward slash (/) as the delimiter of the input fields. In other words, the usage of sed’s search-and-replace is thus: s/searchForThisText/replaceWithThisText/.

      In order to replace (or insert) text that includes a literal forward slash, it needs to be escaped by immediately preceeding it with a backslash. Thus the somewhat-more-cryptic <\/p> closing paragraph tag in the command.

  2. Finally, the result (output) of sed’s changes were redirected to the not-yet-existant ied.txt file using the greater-than sign, >.

Sure, it took me about 20 minutes to read the tutorial and figure out the proper command, but then it would have taken at least 10 minutes to make the changes manually. Of course, the next time I would need to make similar changes, it would take me another ten minutes, and the same is true for all the other future times I would need to make such changes, assuming the file to be changed is the same length or shorter.

And, of course, I can do much more than simply wrap lines of a file in arbitray text with sed. It’s just as powerful, if not more so, than any kind of search-and-replace command in a text editor. And, naturally, it can do much more than just search for text and replace it. But I’ve rambled on enough by now and I’m getting hungry for dinner.

Accessible Web Sites Get More Visitors

Tuesday, September 28th, 2004

If there is still any doubt about why businesses should require that their web pages be accessible, this report from ElectricNewsNet explains how accessible pages can be viewed by more visitors than non-accessible pages.

It also brings up a good point about maintaining that accessibility standard after the site has been created. Accessibility is an ongoing process, and in order to keep your pages accessible any additions to the pages must also be coded accessibility.

“Accessibility is included in the tender and the developers deliver it on day one, but the people updating the site don’t know what to do,” said Michael Byrne, CEO of EIAS.

A Conversation About Email Security with Road Runner

Tuesday, September 28th, 2004

Yesterday I was having a bunch of fun playing with SSH tunnels. While I was at it, I glanced over at Thunderbird when it beeped at me, signifying I had new mail. That’s when I realized that I hadn’t yet taken the time to secure any POP3 or SMTP traffic travelling from my local machines. While I was having all this fun with various SSH shenanigans, I had completely forgotten about one of the simplest things I could do to secure my account: running POP3 and SMTP over SSL, aka POP3S and SMTPS (or SSMTP).

Enabling this kind of connection for my own server was no problem at all. Actually, my web hosting provider is smart enough to offer these services right off the bat, so it was merely a matter of confirming their existence.

telnet my-domain.com pop3s

However, I also have a Road Runner account because those folks are my home ISP. Unsure whether or not they offered these services, I scoured their online help pages but no avail. There was only scant information on security, and most of it had to do with how to block pop up windows in Internet Explorer (a futile excersize anyway).

So I turned next to their online chat support. In order to connect, they required that I fill out my full name and email address in a form (which was not itself secured with HTTPS by the way). Here’s a transcript of my conversation with their representative.

Mike S.: Thank you for choosing Road Runner Technical Chat. My name is Mike S.. May we have the first and last name, and the phone number with the area code of the master account holder?

Meitar: Believe I just gave that to you, but sure: Meitar Mxxxxxx (xxx) xxx-xxxx

Mike S.: Thank you, and with whom am I speaking currently?

Meitar: That’s me. Meitar.

Mike S.: Thank you, what technical issue may we assist you with?

Meitar: I’m wondering if you support pop3s (or POPs) for email?

Mike S.: What is it that you are attempting to do?

Meitar: Use it. If it’s available, I’d much rather retrieve my email via an SSL-secured connection than a plaintext one.

Mike S.: If you are trying to connect to a POP3, then that is fine. If you are attempting to setup a POP3 server on your home connection, this would not be supported, and in fact against the Road Runner Terms of Service Agreement.

Meitar: Nonono, I’m not trying to set up a server, I just want to know if *you* support the protocol.

Meitar: That way I can hit that “Use SSL” checkbox in my Mail program.

Mike S.: If you are connecting to the Road Runner POP3 e-mail server to receive your e-mail messages, you will not be able to set it to SSL. If you are using another POP3 server to receive e-mail from another account, you will have to contact the provider of that POP3 server.

Meitar: So you *don’t* use it, right? I’m connecting to the pop-server.nyc.rr.com machine, whichever that is, for my Road Runner email, in case that helps any.

Mike S.: I am sorry, but I do not understand what it is that you are asking of me. That is the correct POP3 server for the Road Runner e-mail accounts.

Meitar: I’d like to know if my computer can still talk to yours if I tell it to speak POP3S rather than plain-old POP3. I want to know this so that I can set up my mail programs to “use SSL” if your server supports it. As I said before, I’d much rather use an SSL connection than not because I frequently check my mail from hotspots around the city.

Mike S.: As I mentioned, you are not able to “use SSL” for the Road Runner e-mail server.

Meitar: Okay. That’s what I wanted to know. :) As an alternative, do I have access to an SSH account along with my subscription to Road Runner?

Mike S.: Unforunately we do not offer such a service at this time.

Meitar: Hm. Drat…. Well, thanks anyway Mike. Hopefully Road Runner will soon offer secure email alternatives for their customers. :) Have a great rest-of-the-day.

Mike S.: You are very welcome! Have a great day!

Mike S.: If you have no further issues that we can assist you with, you may end the chat session by clicking on the Hang Up button and a chat transcript will be displayed for you. Once again thank you for choosing Road Runner!

In an ongoing effort to continue improving our quality of service, we are conducting a customer survey. If you would like to participate, please copy and paste the following link into your browser: http://help.rr.com/html/chatsurvey.html .

Mike S. Has Disconnected

I couldn’t help but be so nice because he really made me laugh.

Insomniatic Maniac

Monday, September 27th, 2004

The past week has felt like months, though I can only remember 3 days clearly. Read that sentence one more time and tell me if it makes any sense to you, becuase it sure as hell confuses me.

It’s been nearly impossible to sleep. Or more accurately, it’s been very difficult to get myself to fall asleep. I’ve been sleeping just fine, but only after staying up for hours on end. This happens a lot but each time it does I’m left to obey the whims of my sarcadian rhythms rather than my own plans. That’s what’s really bothersome about it: I can’t fall asleep when I want to, only when I’m tired.

Unfortunately, I haven’t really been able to do what I wanted when I’m awake either. I’d like to have more done than what is currently done. I’d like to have more templates for this site, I’d like to have written more, and I’d like to have more paid projects to work on.

There is likely some kind of connection between my own productivity or lack thereof and my sarcadian cycles. Of course, I’m not sure if I’m more productive when I can’t sleep and end up online all night or when I behave like a normal human being and work during the day. I have had conflicting experiencees in both cases so my perception is confused.

Online at night I usually do a lot of reading and learning, but I don’t think I’m very constructive. Perhaps this is because I haven’t the space or the equipment. But maybe that’s just what I tell myself in order not to feel too bad. Productivity is like this mythical holy grail of faith. Sometimes I have it and sometimes I don’t, and I don’t know how to get it or why I lose it.

Ultimately, insomnia is more frustrating than anything else because it implies boredom. No, I’m not really bored when I can’t sleep because, of course, I do all sorts of things. But I don’t think I’ve ever really done exactly what I’ve wanted to do when I’ve been unable to fall asleep. Perhaps what I’d have liked to do is get to sleep. Afterall, that’s why I’m calling it insomnia, right?

Keeping Presentation out of Behavioral JavaScripting

Wednesday, September 22nd, 2004

Lately I’ve been working on a personal project of mine, redesigning and revitilizing my website about Bipolar Disorder. It’s still deeply entrenched in the redesign and I’m not even done with the site templates yet, but I was anxious to get some content rolling out quickly so I went ahead with it anyway.

Some elements of the design, however, relied on dynamic scripting to style appropriately. The key thing here, however, is that I wanted to avoid accessing or manipulating style elements from within the JavaScript script. In other words, I wanted to ensure that all my style rules, the visual declarations for the presentation of these links, would be kept in the site’s CSS.

There were several reasons for this:

  1. To keep presentation clearly separated from behavior and structure.
  2. To keep the JavaScript unobtrusive and portable.
  3. To ensure that both aspects, presentation and behavior could be easily updated or altered in the future.
  4. To allow for various styling without touching the script.

Typically, a JavaScript script with a line similar to elem.style.property = 'value'; is used to create so-called “dynamic styles.” Unfortunately, this would not do for me.

So I fiddled and found that the best way to go about this was to simply tag links that I wanted to style by adding a word to their class name and then write styles for the selected elements inside my stylesheets. In effect, links in my page will be transformed from <a href="http://some.other.site/"></a> to <a class="external" href=”http://some.other.site/”></a> So I sat down and wrote this little plug-and-play JavaScript to tag the links I wanted. Let’s go over it line-by-line. (If you’re antsy, here’s the whole script.)

First, we define a function named catchExternalLinks. Then we set a variable, extClassName, to hold the class name we’re going to add to the links. While not strictly necessary to hold in a variable, it does make for easy editing later. Don’t like the word “external” for a class name? Change it to something else.

function catchExternalLinks()
{
    var extClassName = 'external';

Next, we do some object detection. This is to ensure that the browser can handle what we’re going to ask of it. Browsers that can’t handle it won’t try to, which is good because it means visitors won’t see an error when they visit the site. They just won’t see the dynamic styling.

if (document.links && document.getElementById) {

Now that we know we’re talking only to browsers which can handle our instructions, we define a variable, h (for host), which will store the beginning of the web address that we’re at. On www.maymay.net, h now contains the string http://www.maymay.net.

var h = window.location.protocol + '//' + window.location.host;

Next, we need to gather all the links in our page. We assign the links array to the variable l.

var l = document.links;

We need to work with each link separately, so we loop through the links…

for (var i = 0; i < l.length; i++) {

…and assign the value of the href property to the target variable after turning the string toLowerCase text.

var target = l[i].href.toLowerCase();

We only want to work with real links, so first we make sure we’re not dealing with javascript: directives.

if (target.substr(0, 11) != 'javascript:') {

Then we search the target string of the link for the h string. If we don’t find it…

if (target.substr(0, h.length).indexOf(h) == -1) {

…then this link is an external link so we tag it as such by adding the extClassName to its className preceded by a space. We do this instead of using setAttribute() because this way we can keep any pre-existing values for the class attribute already in the link. The key here is to know that className accesses the class attribute of an element.

    l[i].className += ' ' + extClassName;}

Finally, after closing all our blocks properly, we set the catchExternalLinks function to execute onload.

            }
        }
    }
}
window.onload = catchExternalLinks;

Of course, as per the requirements for this script being as unobtrusive as possible, it won’t do anything to the style properties of the link. All it did was add a class value, so we’ll need to declare our styles in our stylesheet. In my CSS page, I write the following to display a little icon for these links.

a.external {
    padding-right: 15px;
    background: transparent url(extlink.gif) center right no-repeat;
}

The styling possibilities are really rather endless now. Since I can instantly identify external links via the class external, I can also write context-specific styles. For instance, I can limit my styles to only one part of the page with a selector such as

#main a.external { ... }

or I could write different styles for external links for the sidebar and a comment on my entry with

#sidebar a.external { ... }
.blogComment a.external { ... }

or any other styling I see fit. In addition, from the script, it’s very easy to test for links that meet a specific criteria, say, Google definition searches, simply by adding another if clause inside the main loop. Here’s a version that does just that.

All together, it goes like this:

function catchExternalLinks()
{
    var extClassName = 'external';  // the class to set for external links
    var defClassName = 'defSearch'; // the class to set for definition searches
    if (document.links && document.getElementById)
    {
        var h = window.location.protocol + '//' + window.location.host;
        var l = document.links;
        for (var i = 0; i < l.length; i++)
        {
            var target = l[i].href.toLowerCase();
            if (target.substr(0, 11) != 'javascript:') // only work on links that aren't JavaScript directives
            {
                // tag external links
                if (target.substr(0, h.length).indexOf(h) == -1)
                {
                    l[i].className += ' ' + extClassName;
                }
                // tag Google definition search links
                var anchor = l[i].childNodes[0].nodeValue; // anchor now contains the anchor text of the link
                var s = '?q=define:' + anchor;
                if (target.substr(0, target.length).indexOf(s) != -1) // use != to ensure that the string (var s) EXISTS in target
                {
                    l[i].className += ' ' + defClassName;
                    l[i].title = 'Definitions for ' + anchor + ' on the Web.'; // for the link tooltip
                }
            }
        }
    }
}
window.onload = catchExternalLinks;

Feel free to steal this snippet. Just remember to write your styles in a stylesheet that you connect to your page, or the script won’t have any noticeable effect. Of course, that’s the whole point. Enjoy! ;)

Ew. Weblog Chain Letters.

Wednesday, September 22nd, 2004

So as it turns out I had another insomniatic night here at home. As has become rather traditional, I’ve been looking through my copious newsfeeds and reading a lot of news. I like to stay in touch. Through them I got to read about a new variation on the chain letter in an effort to help smaller blogs get noticed on Google.

Eh, I’m not so sure how useful this is because, as a commenter on the post pointed out, it sounds more like a chain letter than anything else.

If small blogs (like myself, by the way!) want to get noticed, we’ll probably go around commenting on other people’s blogs. These are, as you know, links back to our own sites! Using the simple read-and-comment method is even easier nowadays with TrackBack and PingBack functionality built into most weblogging tools. Furthermore, it lets us control with far more precision which sites link to us.

No offense is intended at the originator of this so called “technique,” but I can’t really see the real usefulness of this. Sure, it might give me more links than simply commenting on posts will, but I doubt that’s the only thing that really drives Google’s rankings. Furthermore, it’s not all that helpful for real visitor click-thrus.

In the end, I’d much rather be a small blog with a small but human audience than a large blog with an entirely robotic audience.

The Wonders of Space and Movement

Monday, September 20th, 2004

This is one of those things I would have learned a long time ago. Despite how many times people have told me this, it really didn’t sink in until I managed to do it on a regular basis when I finally moved into my own apartment.

My environment has a huge impact on me. Thus, changing my environment is an incredibly effective tool to weather all sorts of mood swings and changes. In fact, it’s probably one of the most underrated and easiest things to do to improve ones own mood.

Case in point: writing at Chelsea Market. The other day I actually spent hours there sitting at one of the tables blissfully typing away on my laptop. It’s striking because earlier that day I was unsure of what to do and how to spend my time. A simple change of atmosphere, in this case getting out of the house and into a relaxing public market, was both energizing and inspiring.

To be fair to myself, however, it’s not always that easy to actually get up and move. A change in environment can take quite a bit of effort if I’m feeling down or otherwise stuck. I’ve yet to decide whether in those moments I forget the benefits of moving or whether it is simply too hard to actually make the change. Getting up and moving does require some planning. Bring my bag or not? Will I be out long; should I bring books and money? I dread making these kinds of practical choices in the depths of a depressing mood.

One effective strategy, therefore, has been not to make decisions at all. Best personal example I can think of is choosing what to order at a restaurant. My neurotic mind usually has a conversation with itself that follows these lines:

I don’t know what I want. If I pick something I might not like it. If I don’t like it, I won’t really want to eat it. But if I don’t eat it I’ll be hungry, and I’ll want to get something later, so I should pick something now.

I’m not really hungry for something specific though, so I don’t know what to pick.

At this point it cycles and becomes more like circular logic than actual decision-making. At times like these not thinking about choices has proven effective and insightful. I’ve noticed that at first I constantly “messed up” and chose things I didn’t really want. The more I stuck with the technique, however, the more often I chose things I really ended up loving.

Same thing applies to whether, and how, and where, to get myself moving. Sometimes I head over to the Hudson River Park, other times to Saint’s Alp Teahouse, and yet other times to Chelsea Market. I’m lucky because I live in a place where I have all these options, and most of them have Wi-Fi access so I can bring my computer.

Nevertheless, the technique of using one’s environment to affect one’s mood can be a hugely powerful tool. I’ve found that places of commerce tend to get me in a productive mood and inspire me to do things like write, code, focus on work-related tasks, and the like while recreational places like parks, flower gardens, and water-fronts tend to help me relax and slip away from work or an over-active mind.

The same may not be true with you, of course, but I think exploring your environment as a way to effect your moods can be very helpful, and in a very specific, controllable way.