2012-05-24

I code with a catapult

I decided to try something this year. For my entire programming career, I have used a fixed-width font while coding. Of course, when I first started coding, fixed-width fonts were all a computer could do; and even these days, command line interfaces still predominately depend on a fixed-width font for display (especially if they try to draw boxes or other pseudo-graphical elements). Even as I type this blog post using Blogger's HTML editor, the edit window uses fixed-width characters; and if I wrap some text in <code> tags, chances are your browser will also render that text with a fixed-width font (even if Blogger didn't apply a custom style to it). But for a long time now, computers have been able to use proportional-width fonts on screen, and many development tools support picking your own font. Yet, whenever I get the inspiration to try a different typeface in my IDE, I always picked from the list of fixed-width fonts. Visual Studio seems to encourage this by making fixed-width fonts bold in the font dialog.

(Although, admittedly, it is convenient to know which fonts are fixed vs. proportional at a glance, and bolding one or the other is a simple way to show the difference.)

But I had read a handful of blog posts from developers claiming how it is easier to read code when they view it in a proportional-width font. The discussion often includes pros and cons of viewing code in a "literary" font vs. a "computer" font, and often includes a discussion of tabs vs. spaces (the reverse is also true: discussions about tabs vs. spaces often include someone commenting on the benefits of one vs. the other when using a proportional-width font instead of a fixed-width font). I decided that I wanted to try something new, and maybe I'd give this developing-in-a-proportional-width-font thing a try.

The major criterion I've found for picking a font is that it must have very distinct characters. Fonts where a number 1 looks like a capital I looks like a lower case l, where a number 0 looks like a capital O looks like a pair of (), and where (parentheses), [brackets], and {braces} are too similar (or just too "weird"), tend to cause more headaches and annoyances than their otherwise typographical good looks are worth. Also, the font should, obviously, be supported (Visual Studio only supports TrueType fonts in the IDE), and it should be legible (and similar characters distinguishable) at smallish sizes (I tend to view my code at 8 or 9 point). It's also helpful if it's one of the "standard" fonts that is available on nearly every machine (i.e., you don't have to try and find a legal, free download every time you want to use it on a new machine). One proportional-width font that fits these criteria fairly well (no font is perfect on all counts) is Trebuchet MS.

To make a long story short, I'm lovin' it. I've found it much easier on the eyes to read through code. It looks neater, cleaner, more professional, and more tidy (even if the actual code is a mess). And while I realize this "analysis" is all based on subjective, personal preferences, in my opinion a font choice when doing development is exactly that. The proportional font also helps view wider lines on the screen. Now, in an ideal world, you should never let your code lines get so wide that you need to change fonts to read them all, there are times where it is necessary to have a wide line (especially in HTML, where a browser — and I'm not just talking about IE here — behave oddly when you try to insert a line break).

Since commentary on font style is almost never complete without tabs vs. spaces, I'll add my 2¢ here. Personally, I prefer tabs, because they are more compact (one character vs. [number of spaces]), more customizable (most IDEs worth their salt let you specify the size of a "tab stop"), less prone to error (you can type three spaces instead of four, but you can't type half a tab), and easier to navigate (to back up an indent level, you only have to press the left arrow or delete key once, instead of four, six, or eight times). The arguments I've heard for spaces over tabs, I either don't agree with or I don't (personally) think matter: they are uniform across all IDEs (agreed, it is jarring to open a code file in another tool [e.g., a diff tool] and see it display tabs at a very different width), they display the code as written (arrogance; why is the way John Q. Developer aligned the code the "right" or "only" way to view that code?), and they allow for more precise aligning of things like variable declarations (irrelevant; you can tab to the proper indent and use spaces for fine alignment, if necessary). But these are just my opinions, as everyone has their own (and, as a quick scan of the internet shows, some hold to their own opinion with something approaching fanaticism or zealotry that makes it not worth arguing).

I've found that using a proportional-width font seems to work best with tabs, since it helps you keep the code consitently indented no matter which font you use. (Plus, if you prefer larger indents, you end up having to use even more spaces to get the same depth as with a fixed-width font.) However, there is one potential drawback to using a proportional-width font that neither tabs nor spaces can solve, and that's aligning of variable declarations (or other similarly-formatted code blocks). See this picture for an example:

In a proportional-width font, you can't use spaces to align the variable names with the first line. Not only would it vary depending on your choice of font, but there's no guarantee that the sum of the widths of the letters in the variable type is evenly divisible by the width of a space. (You can use tabs to align them with a tab stop, but again, that will depend on the size of your tab stop and whether the variable type name fits within one or two [or more] tab stops.) If that matters enough to you, this may be a deal-breaker; but it's one of the things I've found, in practice, doesn't matter that much when you can just indent the dependent lines like so:

If you haven't tried coding with a proportional-width font, I highly encourage you to give it a try. At best, you might like it. At worst, you can always change it back.

2012-03-18

Old hardware obsolete in Windows 8?

I've come across a minor concern in my trial of Windows 8. In particular, I have noticed some rather disappointing graphics issues with my two-year-old notebook's ATI Radeon HD 4570 chip.

At the right, you can see an image of the Games for Windows Live application Game Room. The only really odd thing about it is the fact that the avatar is a rather generic one, rather than my actual avatar (which the Xbox version of the game uses).

To the right, here, is the same application, running on the same hardware, booted from a Windows 8 partition. The same generic avatar appears here, but with obvious rendering issues. The issues occur also in the "arcade" virtual world, making the arcade impossible to navigate or use (large triangles would block out most of the viewing area).

This picture is of the recent game Microsoft Flight on the same Windows 8 partition. In addition to the wide zebra stripes in the skybox, there are rendering issues with one of the planes that comes free with the game (some invisible triangles, some other triangles that stretch through the cockpit). Oddly enough, the other plane doesn't seem to have that issue. (I would have a picture from Windows 7 picture for comparison, but it won't run on my Windows 7 setup for some reason — it may be time to rebuild the thing.)

I did some internet searching, and there were some suggestions about going to the video card manufacturers' websites to find updated Windows 8 drivers. I checked the AMD website for drivers for my notebook's ATI Radeon Mobility HD 4570. There were Windows 8 Preview drivers for the HD Radeon 5000 series and newer, but nothing for the 4000 series. Some of the websites I found earlier suggested downloading the Windows 7 drivers, just like Windows Vista drivers would work on Windows 7. However, AMD's download site didn't provide direct links to the drivers, just an automated installer application, which refused to install any drivers on my "undetected operating system".

Now, this is just a preview, so it is very possible that, by the time Windows 8 is released, drivers will be available for all of the ATI chips, or that the included drivers will be fully functional. It is just making it rather difficult to make a truly objective assessment of Windows 8 when the only video driver I can use has such obvious issues.

2012-03-11

Thoughts on Windows 8 Preview

On February 29th, Microsoft released the Windows 8 Consumer Preview to the wild, and it quickly scored over a million downloads. I downloaded it and installed it on a separate partition on my laptop. I did this a while back with the Developer Preview, but it was so buggy and didn't really offer me too much at the time that I killed the partition and kept on keepin' on with Windows 7. This time, I've decided to give it more of my time and form some real opinions about it, and — since we live in an age where any idiot with a blog can publish their opinions — I decided to publish this idiot's opinions.

Every day I use the operating system, I have the same thought: this would work great on a tablet. The machine boots up in a fraction of the time as my Windows 7 partition. The new start screen is so much like my Windows Phone, I want to reach out and touch the screen and swipe the tiles around with my fingertips. This would, of course, be futile, since my laptop does not have a touch screen, so there is more than a little awkwardness in using my mouse or touchpad to control the UI. The mouse I use is a Notebook Optical Mouse, which includes a scroll wheel. Using the wheel to pan the Start screen is easy enough, even if it is disconcerting at first to scroll the vertical wheel to move the screen horizontally. As an experiment, I tried disconnecting my mouse and using the laptop's integrated touchpad. The touchpad is multi-touch, so I found I was easily able to scroll the Start screen using two fingers instead of moving the pointer with one.

This does bring me to my first complaint, however: there is really no visual cue or instruction telling me how to get around. While touching the screen to swipe tiles around seems intuitive enough, using the mouse wheel or using two fingers on the touchpad isn't so much. I had to just experiment to see what worked.

This lack of visual cues is a perpetual problem with the OS. For instance, if you install a program, the main program appears on your Start screen. However, it is often the case that a program will, on installation, create a Start Menu folder that contains several shortcuts. It may be true that the most common user story is they will click on the program to run it, but there are often shortcuts to the program's other tools or modes that may be essential at some point (if not an everyday use of the program). Where do those go? It turns out, if you right-click on the Start screen (not on any tile, though; it has to be an empty location on the screen), it brings up a button at the bottom of the screen marked "all programs", and that can be used to see the entire program group. The only way I found this, though, was by random experimentation. If I was looking for these options, there is nothing on the screen that would help me find it except by randomly clicking. This is not efficient task-solving design.

The Start menu itself is also hidden. Once you get off of the Start screen, it's not obvious how to get back to it. You could use the Windows key, but that key no longer looks like the button on the screen it would activate (because that button doesn't exist). You can also throw your mouse into the lower left corner of the screen, where the Start button used to be; but there's nothing on the screen that suggests this is where you need to go to get there.

Another example is the Metro version of Internet Explorer. Its full-screen mode means you don't see so much as an address bar, and although it does support opening multiple web pages in "tabs", these, too, are hidden from view. Bringing these up requires right-clicking on the web page (but not on any real element of the page, otherwise the right-click will bring up an action menu specific to whatever happened to be under your mouse at the time), at which point you can see the URL and all the tabs you have open. Even the Windows Phone version of Internet Explorer doesn't force you to guess this badly; not only is the URL always on-screen (in portrait mode), but there is an ever-present ellipsis button in the lower right that, when tapped, shows you all of your possible actions, including viewing currently-opened tabs. There's really no reason why a laptop can't sacrifice a few pixels of screen real estate for these visual elements when a phone an eighth the size can do it.

One more thing is the side-by-side method of running apps. I know it exists, because I've seen the videos showing it off, but such videos are almost exclusively demonstrated using a touch interface. I do not remember how this is done, let alone how to do it with a mouse and keyboard, and there's nothing on the screen that even hints at what I need to do to activate it. (With these full-screen apps without chrome, there's no title bar to grab and drag to the side like there was with Windows 7.) When I went to find a link to use in this blog post, I had to use the old-fashioned alt-tab combination to switch to a new window and find it, then copy and paste it back here.

Why all this fuss about visual cues? I try to think about the non-computer-literate, specifically my mother and my mother-in-law, and how they would deal with this. Without seeing something on the screen, how would they know what to do? Going to the lower-left to access programs may seem like a second-nature gesture to most of us, but how would anyone expect them to see a blank screen and just know they need to go to this lower corner? How will they know they need to swipe in from the right to see the "charms" (the list of quick actions available to every app)? Even with a computer-literate son or daughter nearby to explain it to them, I would not expect them to have the actions memorized in any reasonable time frame, when computer activity is so little of their day. I have a hard enough time picking up a videogame I haven't played in a couple days and trying to remember all the controls specific to that game, and that's something I do nearly every day.

The whole idea of Metro-style apps on the computer is something I thought at first to be too restrictive. As I've worked with it more, though, I'm finding there aren't nearly as many drawbacks as I originally thought. I'm often only working on one thing at a time, or comparing data between two apps. Having the one full-screen helps me to focus on that window without being distracted by other windows or widgets. Being able to dock two apps side-by-side (if I could figure out how to do it) would probably take care of 95% of my use cases.

However, there are, indeed, drawbacks. I definitely miss not having a clock ever-present in the lower right, or a status tray of icons that I can see, at a glance, what's up with my PC. It's also not immediately apparent what is running on the system — there's a Metro-style Messaging program, which will pop up a notification when a message comes in, but it's not clear to me when it's running or how to start it to make sure those notifications come in. (Contrast that to Skype, which runs as a standard Desktop app, and which, when I'm on the Desktop, I know immediately that it is running.

It's still a little disconcerting having Metro apps and Desktop apps, and a Start screen that doesn't distinguish between the two. When I click on something, I don't know what will happen — will this just open full-screen, or will it take me to the Desktop and add a window there? Why is there a difference? Why do I have to open an app full-screen, or why are there some apps where I can't? It's almost like dual-booting, except there's really no planning ahead and no way to tell which UI is going to handle it.

I do think this would be a great tablet OS, and I would love to have a tablet myself capable of running it. Actually, it would be more correct to say I would love it if my laptop could be used as a tablet (much like the old tablet PCs that failed to take hold of the market a few years ago, pre-iPad). As far as installing the latest and greatest OS on my current machine, I just can't say I'm all that excited about it yet.

2011-12-17

Innocent by Law, Guilty by State Farm

Several months ago, I was involved in a traffic accident. The police officer who arrived on the scene took statements from three witnesses and the other driver before approaching me with a ticket in his hand charging me with "careless driving".

A few things annoyed me about the charge. For one thing, the term "careless driving" is really broad. It doesn't really tell you what you did wrong, just that you didn't do something right. For another, I believed I was following the laws and acting not only according to what I believe was correct (especially with reference to what the Colorado Driver's Handbook says to do at a malfunctioning traffic light), but with how other cars present at the intersection at the time were behaving. Also, the fact that the cop issued the ticket without getting my view, but only that of the other driver and some witnesses, made me feel like the decision was obnoxiously one-sided. Finally, the fact that the officer's report stated the other driver was being cautious didn't fit the facts that, I felt, were obvious.

I was determined to fight what I felt was an unfair assessment. And after finding out how much it would cost to obtain a lawyer (from the one firm that found it worthwhile to actually return my call), I decided I could only afford to fight it if I fought it on my own.

To make a very long story short, the judge agreed with me, that I did take into account the situation (the malfunctioning traffic light, the large number of cars stopped at this light in all directions). One of the witnesses was key in this decision, as she happened to be behind me at the time of the accident, and she testified that I did in fact stop for plenty of time to analyze the situation before entering the intersection. It also sounded like the was about to say the other driver was at fault for entering against a flashing yellow when there was a car already in the intersection (which I was able to prove I had first, by a large margin), before she interrupted herself and gave her ruling, that the prosecution failed to prove my guilt. So, against the odds of representing myself in court, I prevailed.

With that ruling, I thought it would be prudent to contact State Farm and let them know that not only was I found not at fault, but a competent lawyer could likely take this case and go after the other driver's insurance for the loss — hey, if an incompetent fool like myself could win the case, imagine what someone with appropriate skill could do. Boy, was I ever in for a surprise. When I was connected to the agent in charge of processing my claim, and I explained the situation, she told me she didn't think they had a case. And then this State Farm agent proceeded to tell me why: because the other driver had the right of way, she had no obligation to watch for traffic in the intersection because I should not have been there; basically all the arguments the prosecution made at my trial, that were ultimately rejected by the judge. When she mentioned details that were just wrong (like the other driver having a regular yellow light and I ran a red light) and I tried to correct her, she accused me of changing my story. (I don't know if, in the heat of the moment when I first reported the accident, I got some details wrong; but the condition of the traffic light was a fact clearly spelled out in the police report for crying out loud.) She even went so far as to claim that there was no difference between a flashing yellow light and a green light! I was in shock.

I suppose ultimately it's their decision to pursue the case or not, but to just dismiss the results of a trial and accuse me of guilt after I had been found not guilty, does not sit well with me. I believe it is time for me to find a new insurance agent, one that does not stubbornly hold to an assumption of my guilt even after being found not guilty in a court of law, like State Farm has done.

2011-11-21

Hitting the wall

Looks like it might actually happen. With my nephew staying with us while he goes to college, his additional gaming and Netflix bandwidth has pushed our internet usage up over 210MB this month, with still a third of a month to go.

To get comparable internet speeds from Comcast Business (which is not, reportedly, subject to bandwidth caps), I would have to pay triple my current monthly internet bill. I was unable to get comparable numbers from CenturyLink Business (the only other viable internet service provider in my area) without providing my home address and phone number.

My nephew is off spending the Thanksgiving holiday with his immediate family, and I've told my wife we need to use our shiny plastic (and completely unrestricted) discs for home entertainment, so we have a chance of making it through the month under the cap; but now, it's clear that the bandwidth cap is making a clear impact on our internet usage.

It's interesting to note that Microsoft has announced that they are going to be bringing even more streaming video content to the Xbox in the coming months, including (but not limited to) YouTube, UFC shows, and various cable providers' on-demand content (which would be delivered over capped internet, rather than the limitless pipe that carries regular cable content).

Internet use and services are going up (and Comcast even occasionally increases its speeds to deliver more of that content faster), but the cap doesn't move. How many people are going to find themselves over the cap soon? When will Comcast realize "generous" is becoming "too restrictive"? And, most importantly, when will I see a viable option that gives me reliable connection and speed, and the ability to actually use it to its potential?

2011-09-27

So soon, Firefox?

I stepped away for a cup of coffee, and when I came back, there's a new version of Firefox.

I thought my co-worker was kidding, but sure enough, when I started Firefox, it started downloading the installer for version 7.0. Out of curiosity, I went to the options panel to look at the update history. It showed Firefox 5, then Firefox 6, both listed as "security updates" — version 6 installed only last month.

Curiously, after installing version 7, the "update history" list was cleared out. A little embarassing, perhaps?

Seriously, Firefox; this is just silly.

Besides, Chrome has you beat by miles (version 14 as of this post).

2011-08-16

Firefox 6 - Major version, major pain

I was testing out my web code in Firefox today, and I got a message saying that Firefox 6 had been released. Wanting to make sure I was keeping up to date with our users, I installed the update. After restarting the browser when prompted, I noticed that it looked exactly the same. So I went online to check what's new.

Apparently, not much. Oh, there's a small list, but nothing really visible, and it's not really any faster than before. It seems that Mozilla's accelerated release schedule is nothing more than releasing what would normally be a "point release" as a major version instead.

But to what end? Chrome is on version 13; IE's current release is version 9 (with 10 available for preview); Opera is on version 11. Could this be nothing more than a way to "catch up", so "Firefox 5" doesn't sound like it's way behind the other browsers? It was speculated that Microsoft named their second console the "Xbox 360" because "Xbox 2" would sound like it was behind "Playstation 3"; this could be another example of toying with customer mindshare.

Or could it be a way to flush some of the old versions out of general support? Many companies I worked at had a policy such as, "Support the current major browser versions minus two", which today would mean "IE 7 and above, Firefox 4 and above, Chrome 11 and above, etc." — releasing a few major versions quickly would push older browsers that don't support up-and-coming standards like HTML5 out of the support window rather quickly.

Whatever the reason, there is one rather large detrimental effect. Extension authors have to certify that their code is compatible with major releases. Because Firefox just got a new major version number, all of my extensions were marked as "incompatible" and disabled, and that way they will remain until their authors update their xpi packages to mark them as compatible with this new major version. Essential debugging tools like FireQuery, HttpFox, even the Java console are among those that are off-limits until they are updated. Even the extension for the corporate virus scanner is disabled, as is Skype's "click to call" extension (which wasn't marked compatible with Firefox 5 either; not that I use it myself, but I have to be able to confirm that, for customers who do use it, its phone number reformatting doesn't make the page unusable).

Firefox, you used to be cool. I didn't mind inviting you over and letting you crash on my couch. But now you've stolen the food from my cupboards, gotten fat and lazy, started leaving your dirty clothes lying all over the house; and you're wild parties broke my antique table lamp without so much as a "sorry" from you. I grow tired of having to clean up after your mess. IE used to be where you are now, but at least he's been working on cleaning up his act.

2011-08-12

Does courtesy fade with age?

I'm sitting on the train, headphones on, playing a game on my Windows Phone, as normal, when I hear a demanding voice from over my shoulder say, "Do you see that sign!?"

My brain attempts to disengage from my virtual world and process this. Usually, when a voice like that is heard, it's from the train police, asking to see passengers' tickets. But wait, that's not what he asked for. Do I see the sign? There are a few posted signs asking for certain behavior. I'm not playing loud music, I'm not eating or drinking, my feet aren't on the seat… Ok, something's wrong, and I guess I need to turn to this mysterious voice and figure out what it is.

I turn and see an elderly man, looking a bit angry, glaring at me, with his finger pointed at the sign that indicates priority seating for elderly or disabled passengers and asking to comply with all requests to vacate the seat for a disabled passenger.

So, I figured I'd give him the opportunity to request my seat. "Do you want to sit down?"

"DO YOU SEE THAT SIGN?" he yells again.

The people in the rear-facing seat across from me offer their seat and practically stumble over themselves to get up and move to one of the several other vacant seats on the train. "No, I can't sit backwards," the old guy complains after them.

"All right," I said, giving up on any chance of civility with this curmudgeon. I stand up, turn around, and sit in the hastily-vacated rear-facing seat.

The old fart then sits down, pulls out a 12oz Coke bottle, and starts drinking it, right under the sign that says "No Eating or Drinking".

I guess he didn't see the sign.

2011-08-09

RJ11 to RJ14 - easier than I thought

I've just switched from Comcast's VoIP to a third party VoIP provider (the company formerly known as VoIP.com, now a part of Phone Power). When I got my box (slightly smaller than a 3"x5" card and just thick enough to have phone and ethernet jacks on its back), I noticed it had Phone Line 1 and Line 2 as two separate RJ11 jacks. Why they didn't just use a single RJ14 jack is beyond me. It's not like A splitter that takes an RJ14 two-line jack and converts it to two RJ11 one-line jacksline splitters are that expensive — they retail for a couple bucks and probably cost half that wholesale. But where splitters are apparently plentiful, a combiner, something that takes two separate single-line jacks and makes a single two-line jack out of it, is impossible to find in a store and even extremely rare online. So, how was I supposed to take these two RJ11 outputs and plug them into the single RJ14 jack that serves as input for my house wiring?

I found instructions for rewiring a CAT-5 ethernet cable to do the job, but I didn't want to have to buy a crimping tool to form the plugs, nor did I feel comfortable splicing it into existing phone cords (the last time I tried something like that, it ended badly). But then I had a sudden revelation.

You see, there's really nothing special about telephone cord accessories. A splitter just takes the pins in a given plug and wires them to the appropriate pins in the right jacks. In the splitter pictured above, the first pair on the RJ14 plug is wired to both the first (and only) pair on the L1 jack and the first pair on the L1+L2 jack. The second pair on the RJ14 plug is wired to the first (and only) pair on the L2 jack and the second pair on the L1+L2 jack. All those associated pins are interconnected; there is no special circuitry that separates the connections (i.e., nothing keeping the L1 jack and the first pair on L1+L2 from talking to each other) — that's why these things are so cheap. Further, wires are bi-directional. If you apply an input voltage to one end, it will carry it to the other end; conversely, if you apply an input voltage to the other end, it will carry it back to the first end. Wires don't care which end is labeled "input" and "output".

And neither does a splitter. With all the pins interconnected by wires, you can just as easily send a signal input into L1 and L2, and get the combined output in both the L1+L2 and the RJ14 plug on the back side.

So that's what I did. I connected the VoIP adapter's Phone 1 and Phone 2 jacks to the L1 and L2 jacks of a splitter, and connected the L1+L2 jack to my house wiring input jack. (I could've used the RJ14 plug on the splitter itself instead of another phone wire, but there wasn't enough room around the input jack on the patch panel for a splitter to fit.)

So why is this so important that I bothered writing a blog post about it? Because, as I was searching out a solution to this problem (which apparently plagues users of Vonage equipment as well), I couldn't find this very simple solution. Maybe someone else will stumble upon this blog post as they search for their own solution and discover just how easy it is.

2011-08-02

Firefox, jQuery, and event binding, revisited

While I had decided for myself that I didn't want to support Firefox anymore, the company that signs my paychecks respectfully disagreed. Because my project is an internal admin tool, we were able to tell our user base not to use Firefox for the time being and assign the bug a relatively low priority — but, it was something that should be revisited and fixed. Having completed my tasks well ahead of schedule, the time was at hand.

The bug had to do with Firefox failing to fire off a jQuery click event handler. I had long since installed the Firebug extension, but all it could tell me for certain was that the event handler code was not being called. I was fortunate, in my searching, to find another extension, FireQuery, which extends Firebug by adding jQuery information to the debug panels. Installing that and viewing the HTML, I could see that the jQuery click event handler simply wasn't there on the switches that weren't working.

Using the development version of jQuery, I stepped through the code that attaches the event handler, and I could find no difference in code execution between the switches that worked and the ones that didn't (unsurprising, since I attached to all of them at once).

The solution, surprisingly, came about when I started mucking around with elements and styles, substituting divs for lis in a desperate attempt to find the cause. To make a long story short, it was the fact that, later in the code, I called a jQuery plugin called "text-overflow" that emulated the text-overflow: ellipsis stylesheet directive that every browser but Firefox supports.

The problem with the code is that, in order to emulate the feature, the plugin creates a cloned copy of the node to "ellipsify" and progressively removes characters until the width of the cloned node fits in the desired width of the original. Then, it sets the contents to be the new text, and destroys the copy. Unfortunately, there are a couple side effects:

  1. If no truncation happens, the contained elements lose their event bindings, since they end up not being the original elements, but copies.
  2. If truncation does happen, when the contents are replaced with the new text, any other elements contained therein (i.e. hidden form fields holding data for a form post) are wiped out.

The first problem might have been overcome by using jQuery's own clone method which clones nodes and any events associated to them. (This was added after the plugin was written, so I don't fault the author for oversight). To be safe, though, I changed the class on the switches' containers and excluded them from my .ellipsis() call. That successfully kept the slider click event handlers from disappearing.

The second problem was the source of another bug, where a jQuery function attempting to look up values from hidden form fields was failing to find the data on elements that were truncated by the text-overflow plugin. I moved the hidden form fields outside of the elements targeted by the function call, and that, too, was magically fixed.

Internet Explorer has a bad (and well-deserved) reputation for needing special development time to do the same thing that other browsers do (although, in my experience, a lot of this would be unnecessary if it weren't for a requirement, usually from an upper-level executive or, worse, marketing, mandating pixel-perfect replication across all browsers), but I've found lately that the pendulum has swung far the other way to deal with the quirks in Firefox.

2011-07-24

Problem with your phone? We'll call you...

Years ago, I was somewhat amused when we had a problem with our internet, and when I called Comcast service, the automated message suggested reporting the problem on their website.

Last week, when our internet went out and took the Comcast VOIP service with it, we had to call Comcast customer service from our cell phone and set up service. The customer service rep asked if there was a phone number by which we could be contacted (since our home phone was out), and we gave them the cell number.

Today, I finally got around to checking the messages on Comcast voice mail that came in while our service was out. The message left was from Comcast customer service, telling us we had an appointment set up.

insert eye roll here

2011-07-19

Why is the internet not a utility?

I've been following the plight of Ozymandias and his issues with Comcast cutting off his service with great interest, since I've been concerned with their bandwidth caps since they announced them about three years ago. He has argued that, because of how important internet usage has become in this day and age, it should be considered a "utility" instead of a generic service. I don't disagree, and my own recent experiences helped bring this point home.

Recently, my mother had issues with her Comcast phone service, where she had not had a dial tone for a few days. Having a busy work schedule and some remodeling done on her house, she didn't get around to calling Comcast about it for some time. When she finally called Comcast to get it resolved, the tech on the phone determined the cable modem was working correctly, but it was reporting a phone off the hook somewhere in the house. Because she had no phone service, however, the tech said she would schedule a service call at the first opportunity — which, due to severe storms in the area, would be the next day; notable since that next day was a Sunday.

Note that this was not Comcast's fault. I happened to be over to help with some other items, and as I was there, I noticed that one of her contractors had inexplicably taken a network cord from a hub in the office and plugged it into a phone jack. Once I pulled that plug, dial tone was restored.

Over the past couple days, we've been having issues with our internet going up and down intermittently. Yesterday, it was bad enough that our phone service went with it, too. (It could easily have been going up and down all along as well, but this was the first we'd actually noticed it.) My wife called Comcast, and they said that because we weren't getting a dial tone, they would send a tech out that day — which they did.

The reason I find this interesting is, in both cases, Comcast sounded like they were more motivated to act not because the internet service was down (in my mother's case, her internet service was fine), but because there was no phone service. I did a very quick internet search, and although I couldn't find an official statement, I found several allusions to law that require a dial tone be available for everyone for 911 service at a minimum. If this is true, it would certainly explain their motivation in getting service restored.

But it does bring up a few interesting questions. First, if I had my VOIP phone service through some other provider, such that my phone service depended on my internet even though Comcast itself was not providing that phone service, would they be likewise motivated and/or obligated to get my internet service restored in the event of an outage? Although my cynical side believes no simply on the grounds that they're not responsible for that service, I think the fact that any competing VOIP provider's traffic is subject to the bandwidth cap whose penalty is a disconnection of service, is evidence that they would not, in fact, take a loss of non-Comcast VOIP as reason to expedite internet service repair.

Second, if you get your VOIP through Comcast, does this mean they can't eliminate your service completely if you go over their bandwidth cap? This one, I'm a little uncertain about. I don't know if it's possible to get Comcast phone without Comcast internet. Maybe you can, and maybe the 1 year ban on Comcast service only applies to the internet service and not phone (or TV for that matter). I don't know about this one.

Third, and most important I think: if telephone service is a utility, and its function is directly dependent on internet service (as is the case of VOIP), how is internet service not a utility? I suppose one could argue that service could still be provided by the copper wires still in place left by US West Qwest CenturyLink, but I'm not so sure; not only are those lines disconnected (as evidenced by my complete loss of dial tone when Comcast VOIP was down), but it wouldn't explain why Comcast seems so concerned when their dial tone is not being provided. By failing or refusing to provide the service that telephone depends on (when the internet is down, or Comcast cuts you off for so-called "excessive use"), Comcast effectively cuts off your access to a utility. It would seem that they should either be obligated to provide your service, or re-connect your copper lines to get at least emergency dial tone service restored as soon as possible.


Now, a hype and gripe about Comcast service. First, the gripe: when the tech came out to fix our service, the modem was getting an inconsistent signal, so he decided to replace the (leased) modem with a newer model. The new model, an SMC model SMCD3GNV, had some extra features, like a built-in router with four gigabit ethernet ports and a WiFi access point. While this might be convenient for some, it was not for me. I already had a Linux server acting as my home router, and I had my own WiFi access points configured for my home network. I did not want an extra level of NAT or another WiFi network, even if I never used it. Unfortunately, the ability to either disable NAT or turn off WiFi were not available in the modem's UI. Doing a little internet searching, I found that this was a common complaint. While I was able to set up a serviceable alternative by putting my server in the router's DMZ, I still was not happy with the double-NAT, and I definitely was not comfortable with the enabled WiFi.

Now, the hype. The Comcast tech, Justin, promised he would ask his more experienced techs about this the next morning and find a solution for me. In the meantime, my internet searches pointed to the fact that some of these "advanced" configurations could (only) be done by Comcast remotely, and contacting the Twitter account @ComcastCares can get the WiFi turned off. I also came across a recommendation to contact an admin on the Comcast forums. I did both. As I was composing my message to the forum admin, I got a reply from someone monitoring @ComcastCares, who, after getting my service phone number, promised to have a tech take care of it in the morning.

The next morning, I saw a reply from @ComcastCares saying they had turned the WiFi off. I then saw a slightly later reply from the forum admin, saying the WiFi had already been turned off, but he put the modem into bridging mode, and that I should be able to control everything from my own router again. Since I was already at work, I had to call my wife and walk her through the steps to reset networking on the Linux server, and as soon as she did and networking came back up, everything was back to normal.

I called Justin (who had left me his cell number) to let him know we were ok, and he thanked me for the call, as he had talked with techs in his office about the issue (and their frustrations at not being able to change these settings themselves), and was preparing to make another trip out to simply replace that modem with one that didn't try to do everything for me.

Kind of a crappy situation brought on by Comcast's own choice in modems and firmware with inaccessible configuration settings, but the three people involved were willing and able to work through it to get me what I wanted.

2011-07-16

My $6000 mistake

After my 2004 Prius was totaled, I had one prevaling thought when it came to transportation: I needed to replace the car. As such, I went looking for another Prius, loaded, with the JBL sound system, bluetooth, and GPS navigation. My wife strongly encouraged me to look for a later model, as it would be better covered by warranties and have less of a chance of something going wrong. Because rising gas prices have been driving up the demand for hybrids, and because the recent tsunami in Japan was hindering supply, my choices were rather limited. I found a couple dealers with Priuses, and it came down to a 2005 base model and a 2009 loaded touring edition. The '05, without any options, felt too much like "just a car"; while the loaded '09 offered all the bells and whistles I was used to, plus had newer components which made for a better warranty and piece of mind.

The cost, however, was really tough to swallow. After the check from my insurance company, I ended up owing over $13k, which I financed with the intention of pulling money from various accounts and paying off as soon as possible.

After a couple weeks of driving, however, I noticed the strong new car scent had given way to a strong cigarette smell. Not a smoker myself, the smell was beyond irritating — and the fact that I take my kids to school in the morning made me more concerned about the environment I was using for transportation. This and the out-of-pocket expense weighed heavily on me for the following weeks.

When fabric cleaners and deodorizers failed to improve things, I came to the conclusion that I had made a terrible mistake.

I knew I would take a small bath on the cost of the car compared to its trade-in value, so I began the search for an inexpensive and economical car (and, to satisfy my wife's concerns about warranties, a relatively late-model with a good warranty). My search led me to a used 2010 Chevy Cobalt previously used as a rental car, which I couldn't beat for the mileage/year/economy at that price.

It's a good car, drives well, is comfortable, and, very imporantly, does not have a cigarette smell. It doesn't have the bells and whistles of the Prius, but those are features I didn't really need — my phone can serve as a GPS well enough (and one that's continually up-to-date), and plugging the phone's headphone jack into the stereo's auxillary input (which I do out of habit anyway, as I listen to podcasts or audiobooks almost exclusively) is a more-than-acceptable substitute for a wireless handsfree bluetooth connection. Plus, the Cobalt has features that even the 2009 Prius didn't: a tire pressure and oil life monitor, daytime running lights, automatic headlights (seriously, for all the bells and whistles, how can the Prius not have automatic headlights?), and doors that automatically lock when the car is in gear. Plus, the Cobalt does not attempt to control everything through a single LCD touchscreen. (It seems cool, but it ends up being far more distracting and annoying when you have to switch screen modes just to adjust the temperature or see what radio station is playing — which might be why the 2010 model Prius went back to discrete radio and climate control panels.)

The car cost me just about the exact price of my late Prius, but after figuring in the loss on trade-in, taxes, and two dealer delivery charges, I estimate I lost somewhere in the ballpark of $6000 on the deal. But it was a huge weight off of my mind to be able to pull that money together, write a single check, and buy the car outright without any financing whatsoever.

The cost all comes down to a simple mistake. When I went to get a replacement car, I focused on replacing my old car with a near-equal match. If I had instead focused on what I need instead of what I want, I could have avoided the extra cost — or taken that extra money and considered more expensive but more economical or featured cars.

Do I miss my old Prius? Absolutely. It was my fun car, and I enjoyed it for the nearly seven years I was privileged to drive it. I'm glad I was able to get my fun car. But what I didn't initially accept was, it was time to move on. Now that I've accepted that, I feel much better about my old car's replacement, and I can move ahead.

2011-07-11

The Day Comcast's Data Cap Policy Killed My Internet for 1 Year

I've long complained about internet data caps. While I haven't yet exceeded Comcast's 250GB cap, I noticed a blog post retweeted across Twitter with a real-life anecdote of one person's experience getting cut off from Comcast internet service for doing just that. link

In his case, service was likely* due to an increase in uploading large files to cloud services that are becoming more and more popular. My own usage is still primarily downloading data (above 95% of my monthly use is downloading); but as we have new Windows 7 smartphones that automatically upload pictures to the Skydrive service, and the upcoming Mango update promises to do the same with HD videos as well, I can see uploading rates increasing for me as well.

*"Likely", because Comcast does not provide details about data usage, even to show how much is up- vs. downloading.

I do find it odd that, instead of charging for overages and milking more money out of their customers, they are throwing customers away. I imagine there are users who would much rather pay extra than being cut off completely. And yet, they are effectively reducing their customer base, which will only shrink more as more people go over the cap by daring to use all these internet services other companies are so keen in innovating, which will only happen more often when Comcast refuses to increase the cap proportionally to how many services are available, the increase in bandwidth existing services use (i.e. more HD video available for streaming), and the increasing speed Comcast itself is providing to get to their arbitrary cap faster.

2011-06-24

You have failed me for the last time, Firefox

In my last post, I mentioned that Firefox was causing issues with my custom on/off control. I solved that problem, but now I have a new one.

When the on/off control renders, it renders with an onclick attribute that calls the function that moves the slider and sets the value of the control in a hidden field. If I want to add any more actions to the control (a common one is to change its color when the value is changed), I use the jQuery .click() function to attach a JavaScript function to its click event.

On a page with several on/off controls, I have bound click events to change their color and enable a save button on change. It's worked every other time I've done this, and it works in this case as well — except for Firefox. For some reason, the last group of controls (which happen to be rendered in an ASP Repeater) do not fire the jQuery click event. What's worse, even though clicking on them does in fact slide the button from one value to the other, it apparently is not setting the hidden form field to change the value — and all that code is being run from JavaScript called in the onclick attribute.

I have found numerous references to jQuery click events not being fired in Firefox, but none of the solutions will help me here. I can't move my code into the onclick event, since I need to register the click handlers from different places; and nothing is apparently wrong with the code as it works as-is not only in other browsers, but in the same browser elsewhere on the same page.

I have spent the better part of a day trying to find where this click event is being "swallowed", and why this code that works perfectly on IE, Opera, and Chrome is not functioning in Firefox. I'm done. It's an internal tool, and we have the luxury to mandate our users' browser choice to some degree.

Firefox, I don't know what your problem is, but I am tired of wasting days of development time trying to find solutions for problems that only exist in Firefox. You are the weakest link. Goodbye.

2011-06-17

Firefox, jQuery, and RegisterStartupScript

I have created a control for the web project I'm working on at work. It's an On/Off slider control, very similar in appearance to the one used by iOS, that uses jQuery to animate the sliding switch on click. Over time, I've added more features and support to it as requirements have come in — its message text is configurable, it can raise its own postback events, and it even works in AJAX postbacks. Someday, I might have to publish the code (maybe when I get rid of its dependence on images and make it size-adjustable as well).

When the control is first rendered, the slider switch is centered halfway between "On" and "Off", and I call Page.ClientScript.RegisterClientScriptBlock that calls that control's "set" function to slide the switch to the correct position. (The control's client click event sets the control's value property and calls this same function to slide the switch back and forth on demand.) It works great on IE, Opera, Chrome… but not Firefox. It would render the first few correctly, but somewhere halfway down the page (depending on how many switches were involved — my particular example page had 10), the slider switches would remain in their centered, "unset" state.

This is getting to be a theme.

I found that, if I added an alert() call before every SetSlider call, then every switch would be set, except the last one. If I reversed the calls so the alert() came second, all the switches would be set.

I was able to solve the problem by wrapping each SetSlider call in a jQuery ready function (i.e., $(function(){ … });). Because the control is self-contained and has no knowledge of other sliders on the page, that's a lot of ready functions; but jQuery seems to handle it without incident. The only other thing I had to deal with was to ensure any startup functions I had to alter the switches' states must come after those SetSlider functions — in my case, moving the code to the page's PreRenderComplete event (because, according to MSDN, the controls' PreRender events, where I registered the SetSlider methods, get called after the page's).

It works, but it still took a couple hours out of my day to find it and then fix it. Thanks again, Firefox.

2011-05-26

When it rains, it pours

You know, it would be nice if manure didn't hit the fan all at one time… for once.

A week ago today, my car was hit in an accident, which the cop blamed me for (still building my case against this for my court date in 2 months). Sunday, I tried helping my wife cook by slicing carrots on the mandoline, when my thumb must've slipped, and I cut about a quarter inch into the end of my thumb. Tuesday, I got a call from insurance telling me they're totaling the car, putting me in the difficult decision of fixing it and never expecting to resell it, or shelling out around ten grand on top of my car's value to replace it (since, with the earthquake in Japan and rising fuel costs, Priuses are getting hard to find). Wednesday, my wife called me to tell me she got a ticket for making a right turn on red where allegedly there is a sign saying not to do that. That night, at some point between picking my mother up from her house and going to a Toyota dealership to look for used Priuses before picking her truck up from the shop, my stereo bluetooth headset disappeared (a search of every place I had been since I last remember having it turned up nothing).

At least, as before, God gave me an umbrella. I was uninjured in the accident. I seem to be getting all the documentation I need to argue my case. We actually have money in savings (barely) to replace the car. The amount they offered me for the car is actually quite fair. The cut on my thumb was clean and somewhere between a quarter and a third through, shallow enough that it did not require any "reattachment". My wife's traffic ticket, if paid promptly, will only result in a single point against her and not affect insurance. I "get" to upgrade my car, not to mention change its color (I always hated the color of the one I've been driving for the past 6½ years), and I'm getting more for my car than the trade-in value the last dealer offered me.

It still would be nice if all the bad stuff would stop now.

2011-05-19

Maybe treating it as a four-way stop is best

Long ago, I wrote about my annoyance at people who get the rules about malfunctioning lights backwards. I rather wish I had one of those "ignorant" people on the road today.

At the intersection leading into the train station, the lights were completely out. Four-way stop. I was going straight. As I stopped, the car next to me turning left started to go, so I did as well. Someone coming from the cross street in the far lane (on the other side of a full lane of traffic at a stop) plowed through the intersection and hit me.

As I sat in my car (the door was jammed, so I couldn't get out right away), I looked up to verify the lights were in fact dark. They were — in my direction only. The lights in the opposite direction, however, were flashing red, and the lights on the cross street, the one the other driver "plowed through", were flashing yellow.

We both acted on information we had; the street light just gave two completely different sets of information.

I made sure to point this fact out to the officer on the scene, who noted it. I do have to appear in court in a couple months to answer a charge of "careless driving" because I failed to yield to her yellow light, so I can only hope the judge will acknowledge the screwed up lights and realize I acted appropriately.

Of course, it wasn't until I was on the train in to work that I realized I should have taken pictures and video, especially of the lights in question.

2011-05-15

Want to fly? Change your plans.

So, my mother was supposed to fly out on business today. We called to see if she had made it and if there was anything she needed. What did she say?

They downsized her plane and bumped her because she did not check in the day before the flight.

The next flight available? Tomorrow, 4pm.

So any and all plans she had for today and tomorrow, including business meetings, have to be canceled or rescheduled.

Add this to other horror stories we've heard first-hand — including friends of ours who were bumped at the last minute and forced to delay their return home for a whole weekend with their two young children (did I mention that the airline had already put their luggage on the flight, so this family of four had no clothes for that weekend?) — and is it any wonder why I'd rather spend hours in a car driving to far away destinations than giving any money to this industry?

And this is before factoring things in like insane surcharges for every little thing, and your choice of rape or pornography to get through security.…

2011-05-11

My Jury Service

A month or so ago, I received a summons in the mail to report for jury duty. I let my employer know well ahead of time, and on the designated day (Friday), I reported to the county courthouse.

I show up at 8am Friday morning. I went through a security checkpoint that reminded me of the good old days of airport security, when it didn't include taking off your shoes and submitting to a physical search that would only be appropriate in an after-school special titled "Bad Touch". In the jury room (a very large room with hundreds of chairs laid out in even rows), I picked up a questionnaire and started filling it out, while Fox News displayed on two TVs in the front.

The questionnaire included a lot of personal questions, including things like "Have you or anyone in your family had an experience with a law enforcement officer recently? Was it positive or negative?" They also included the name of the person on trial and a long list of names of potential witnesses, asking if you knew or recognized anyone. It also asked if there would be any difficulty serving the length of the trial, which was expected to last eight days.

When I was last summoned, I was very upset that, as a contractor, I was only guaranteed the low legal limit of $50/day. Now, as a full-time employee, I'd get my full pay, but only for the first three days, and then I'd be at that below-minimum-wage rate. (Colorado minimum wage is currently $7.36/hour, working out to not quite $60 per day.) I'm not much happier about this.

Time passed as more jurors reported in and started filling out their questionnaires. After about an hour, the clerk addressed us, along with a judge, to thank us for our service and tell us how important jury service is. We then watched a short video about jury service, in which people shared their thoughts about service. I noticed that the testimonials included valid concerns (like "I had small children, and I worried about what I was going to do with them", "I was really busy at work and didn't know how I'd fit this in"), but then they said how good they felt doing their civic duty — without addressing any of the concerns they initially expressed. (So, what did you do with your kids, ma'am? How did you support your family making less than minimum wage, sir?)

Our questionnaires were then gathered, at which point we were given a new randomized juror number. We were then sent home, with instructions to call a certain number after 6pm to see if we were selected to return on Monday.

This seemed like an unfair inconvenience. I was unable to tell my employer if I would be at work on Monday or not until after office hours were closed. I suppose my employer wouldn't know how long I would be out anyway, and the judge and attorneys need time to go through the 150-some questionnaires, but still, it doesn't seem like the needs of the citizens are taken into account at all.

I called, and sure enough, I was selected to return on Monday. I sent an email to my employer to give them what notice I could.

On Monday, I reported at the designated 9am time (which at least gave me plenty of time to drop my kids off at school, as usual). Reporting in were the hundred or so jurors from Friday selected to return, plus another group asked to report for the first time on Monday. The Monday jurors were processed first. The clerk announced that their trial was expected to take five days. They filled out their own questionnaires, and again we watched the video, temporarily interrupting the CNN discussion of Osama Bin Laden that was playing on the TVs today. I noticed that the video stated the average trial lasts 1-3 days, and I couldn't help but wonder how many trials must last less than a day to get that average down, considering our trial was 8 and theirs was 5.

Finally, around 10:30am, we were sent up to the courtroom. There was probably at least 20 minutes spent getting everyone seated, as we were supposed to sit in order of our juror numbers in a particular configuration around the courtroom. (The judge and attorneys had seating charts, and this would ensure they knew to whom they were speaking.) Some additional jurors had been dismissed, so there were some holes in the jury box. The first of us on the benches were called up to fill in the holes. As luck would have it, I was the first in line and ended up in the jury box to start. When I was in jury selection 6 years ago, I noticed that those people in the jury box at the beginning were among the first to be dismissed, and those called to replace them rarely were; so I had good feelings about being dismissed before hitting a substantial drop in income for a few days.

Questioning began (what is known in the court as voir dire — I guess I did learn something from that jury service video). The judge started with basic questions, such as whether or not any of us knew or recognized anyone else in the courtroom — including the defendant, whom I was honestly surprised to see present. I don't remember the defendant being present the last time I went through this, and I have to wonder if any of the potential jurors felt uncomfortable answering questions in front of him.

One of the questions the judge asked every juror was if there was any hardship in serving. I mentioned that the drop in pay would make it very difficult to support my family. He did say that, if it meant falling behind in bills, he would not keep anyone there. I answered honestly that it would be difficult, but I would at least survive. (It would take dipping into savings, but it would have been possible. I could've lied and said it would've been worse, but I didn't think that would be prudent, especially since we had a lesson in church the day before that just happened to be all about honesty.)

After the judge got through everyone, the prosecuting attorney began asking questions, probing for any biases that may make judging this particular case difficult. I was asked one question directly, but then I noticed that he didn't seem that interested in me thereafter. So, after our lunch break (during which I went to Walgreens to get some Excedrin for the headache that was building up all morning), I decided to remedy this situation. Whenever the attorney asked a general question ("Does anyone else feel like this?"), I raised my hand. Well, any time I could come up with something to say, anyway. I answered honestly, but I tried to answer a lot, so when it came time for the attorneys to dismiss jurors, I was on their mind.

When it came time for the dismissals (peremptory challenges — something I don't think was in the video but was explained at length by the judge), I ended up being dismissed by the defense attorney. I think about five people were dismissed before me, sent downstairs to collect their certificates of service (among other things, used as proof to employers of time served). They must have been discussing who they thought would remain on the jury, because when I showed up, there was a collective look of astonishment on their faces as one said, "You? No way, I thought you were a shoe-in!"

I'm not sure if I said anything in particular that got me dismissed. There was a question asked by the defense attorney along the lines of, "Could someone have a legitimate reason to lie to the police? If they do, does that mean they must be guilty of something?" I answered (honestly) that I wouldn't think they were "guilty", but it would color my perception of their testimony — if they lied to the police about one thing, what else might they lie about? While I can't know the specifics of the case, he must've had a reason for asking; I would guess that either the defendant or one of his witnesses might've lied to the police during the course of the crime/investigation, and my opinion might lead me to discount their integrity. Or maybe it was just my visibility in questioning, or a combination of both. Whatever the case, I wasn't too upset to not have to worry about supporting my family for the next week and a half.

In a way, I'm kind of disappointed I didn't get to hear the case. The charges were read to us, so I know it had to do with domestic violence and second degree murder. I would've been much more willing to serve in this very important process, too, if they didn't make it so blasted difficult to take care of your regular life in order to do this service.