Everything In Between

The brutally honest, first-person account of Meitar Moscovitz's life.

Archive for October, 2004

Baffling IE Behavior with PNG Opacity Fix

one comment

This has been baffling me to no end for the past few days. I’ve exhausted my own skill to figure the problem out, so I’m putting it up here in the hopes that someone more knowledgeable than I can solve the puzzle.

The other day I was browsing message board posts and someone was asking for information on how to get Internet Explorer to play nice with variable opacity PNG images. I suggested that she try Andrew Gregory‘s Improved PNG Behavior file for IE which the poster did. However, she reported the most unusual thing: when implemented on her page, all of her images vanished from view!

Puzzled, I made my own (very ugly) test pages for three different versions of the behavior file. Surprisingly, when I tested Andrew’s behavior file the PNG image on my page vanished too! So I dove into the the code and traced the problem down to line 54 of his file, which reads: element.runtimeStyle.filter = ''; // remove filter.

Commenting that line out solved the disappearing image problem, but it seemed like a messy hack more than a fix. I had to assume he put the line in there for a reason. So I decided to litter the functions in the file with alert()‘s to help me visualize the problem. Then I noticed the most bizarre thing. Inside the fixImage() function, both the if block and the else block were executing procedurally. That is, first the statements in the if block executed and applied the appropriate IE filter to the PNG image, but then the else block was executing right afterwards and was removing the filter even though the if block had evaluated to a boolean true!

Here is the relevant code I was working with (some comments, and the alert()s added by me):

function fixImage() {
  // check for real change
  if (realSrc && (element.src == realSrc) && IS_PNG.test(element.src)) {
    element.src = blankSrc;
    alert("element.src set to " + blankSrc); // help debug
  } else {
    if (element.src != blankSrc) {
      // backup old src
      realSrc = element.src;
    }
    // test for png
    if (realSrc && IS_PNG.test(realSrc)) {
      alert("fixImage() 'test for png' IF statement executing"); // help debug
      element.src = blankSrc;
      element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + realSrc + "',sizingMethod='scale')";
    } else {
/*
?? It apparently causes any fix[ed]Image() to disappear! Not sure why it even executes,
?? because the if block above executes too...and doesn't that mean that the else
?? statement should not execute?!?!
*/
      alert("Inside fixImage() 'test for png' else statement: removing filter..."); // help debug
      element.runtimeStyle.filter = ''; // remove filter
    }
  }
}

So now I’m really puzzled. What’s going on? I emailed Andrew on the matter and he said that he couldn’t replicate this behavior. I am testing this in the latest Internet Explorer 6 on Windows XP Home with Service Pack 2 installed. (Or, to be completely anally retentive, version 6.0.2900.2180.xpsp_sp2_rtm.040803-2158 as reported by Help → About Internet Explorer.) He was using the latest IE 6 on Windows 2000, however, so maybe the two versions are different somehow.

All the code is in my PNG test directory and the relevant page is the improved_pngtest.html document. The .htc file is called from within that document. If anyone out there is bored or wants to try figuring out what’s happening in IE, I’d be very interested to hear about your findings.

I should also point out that Andrew has updated and re-written some parts of this function his new file works without any problems even on my configuration. I’d still like to figure out why IE is executing else statements after their respective if blocks have executed though.

Written by Meitar

October 22nd, 2004 at 1:57 am

Posted in JavaScript

Okay then, new integrated back end!

2 comments

Well, last night I said it was stupid to keep running one domain as if it were two sites. So, though I’ll keep the front-end of this site separated so as not to mix business with pleasure (too much), I’ve decided to integrate the whole thingamabobber into a single actual blog/database/backend/etc. That should keep things simpler for me. Have yet to reconstruct the categories, but that is only a ten minute task.

‘Bout time I started streamlining and compiling all my collected works under a single roof. Sheesh!

To do:

  1. Filter which posts are posted on Maymay Media’s blog somehow. Some options:
    • built-in WordPress functionality? I don’t know of any yet.
    • RSS category-specific feeds. (Unnecessarily taxing on my server.)
    • Simple database connect and filter via category by rolling my own code.
  2. Finish up the categories.

Written by Meitar

October 21st, 2004 at 6:57 am

Posted in Site Updates

Random Thoughts and Fibonacci Sequences

2 comments

I know I promised more writings on bipolar disorder. In a rather fitting and repetitive twist of fate, I was feeling too moody to write about being moody.

Instead, in order to keep myself from feeling unproductive, I started learning C programming. After trying the obligatory “hello world” program, I made a simple guess-my-birthday game. After that, I wanted to learn how to parse command-line options and arguments. I first needed an application that could take options, however, so I wrote a quick ‘n dirty Fibonacci sequence calculator. The first incarnation used an array to allocate some appropriate chunks of memory and then performed the calculations in one pass over the array.

It was simplistic, but wasteful. After posting a messag to the Orkut C Programming community, it was suggested that I use a recursive function to calculate the sequence. One number at a time is simpler and more memory-efficient. So I re-wrote the core function. Finally, I added switches for both starting numbers and the length of the sequence option.

Would like to see if I can add a few other options just for similar academic purposes like a delimiter (instead of the default newline) and an output file.

Other thoughts:

  • Really don’t like the idea of keeping two separate sites (one for BPD, one for my work). I think I’ll combine both blogs into one and just turn feed the Maymay Media site blog postings from appropriate categories that I post here.
  • Both these sites need redesigns. Would be willing to hire designers to get the job done.
  • I missed the opportunity to register to vote. That’s frustrating but I have only myself to blame.
  • Apartment hunting has proven fruitless for the time being. I also hate the idea of not living within three blocks of everything.

Written by Meitar

October 21st, 2004 at 4:06 am

GPGMail with Fink’s GPG Port

one comment

I have been using Mozilla Thunderbird as my default (and only) email client application on my Windoze laptop for a while now. (It’s far better for email than Outlook in just about every way.) I’ve also been using the Enigmail encrypted email extension. I’ve even been able to get my mother into using it to send me sensitive emails, such as when she wants me to order something for her on Amazon.com and needs to give me her credit card number to do so.

This has a number of advantages:

  1. The message’s security is on-par with some of the best privacy encryption around. The telephone is a surprisingly easy communication channel to compromise. At least sending an encrypted email (assuming keyloggers aren’t present on a compromised system and assuming the private keys are kept safe) will take some more intense computational power to crack.
  2. I’m basically guaranteed to recieve the communiqué; my cell phone provider has the worst reception and delays imagineable. I’m always available by email, however, because I check it as if I’m paranoid.
  3. Best of all, my mother need not call me as often as she once has. (No offense, I love you Mom.)

Anyway, the point is that I had wanted to now integrate GPG with Apple’s Mail.app, had heard about GPGMail, but was worried that it wouldn’t work because it says it needs MacGPG, and I have Fink’s GPG port.

Being the blatantly insubordinate individual and anti-authoritarian that I am, I decided to try to work with it anyway and see what would break. So I installed GPGMail and launched Mail.app. I was presented with the error, “Invalid crypto engine! GPGMail cannot work. It didn’t find GnuPG (/usr/local/bin/gpg) with at least version 1.2.2. Please quit Mail, blah blah blah blah!”

So, thinking that maybe that path was just hardcoded into GPGMail, I created a symbolic link from /usr/local/bin/gpg which pointed to my Fink gpg installation at /sw/bin/gpg.

sudo ln -s /sw/bin/gpg /usr/local/bin/gpg

Much to my delight, it worked wonderfully. Luckily, it turns out that GPGMail can work just fine with GPG ports other than MacGPG. You just have to tell it where your gpg executable is.

Written by Meitar

October 16th, 2004 at 6:46 pm

View the Web Your Way with Edit CSS

2 comments

For a while I have been using the Web Developer Toolbar in Firefox for various puroses. It’s extremely helpful, allowing me to quickly and easily outline custom elements, display the rendered sizes of block-level elements, provide an overview of the page’s structure without fiddling with the DOM inspector (choose CSS → View Style Information… and then look at the status bar as you move your mouse over the page), and much more.

However, I’ve also actually been using it to make my experience on the Web more my own.

Introducing Edit CSS

One especially useful option in the Web Developer Toolbar for the Firefox and Mozilla Web browsers is the “Edit CSS” option. You can get at it from the Tools Menu → Web Developer → CSS → Edit CSS or by pressing CTRL + SHIFT + E. This will show the browser sidebar and, if any exist, load the existing styles applied to the page you’re viewing in a large text-entry field.

To use the feature, simply start typing in some applicable CSS. On each keypress, Firefox evauluates your style rules and applies any changes as appropriate. In other words, you can edit the styles of any page you visit faster and easier than ever before, and your changes are displayed live, as you type!

I like this a lot, because it further develops the application of the philosophy that giving the user more control over his or her environment is a good thing. Here are some examples of how to start making this new power work for you right away.

Exercise Your Power

  1. The next time you come across a web site whose entire textual content is centered on the page (we all know how annoying that is), open your Edit CSS sidebar and type the following:

    * { text-align: left; }

    This will immediately left-justify all text on the page. Now you can read with ease!

  2. To further help readability on pages whose line lengths span the whole screen, add a suitable maximum width for your reading pleasure:

    * { max-width: 40em; }

    Now all elements on the page won’t be wider than 40 em’s which should be comfortable for most people. Of course, feel free to substitute your own value in place of mine. That’s the beauty of it.

  3. If the author of the page you’re viewing has chosen a horrendously annoying shade of pink or yellow to display text in (often coupled with an equally unreadable choice of background color), just open your Edit CSS sidebar and type the following:

    * { color: black; background: white; }

    Now you have easy-to-read text and you don’t have to strain your eyes. Again, simply swap the values for white text on a black background to inverse the colors, or feel free to use your own preffered colors.

What if the page doesn’t change?

If the page you’re viewing hasn’t changed after typing these lines in the Edit CSS sidebar, then you’ve either mistyped something or another rule later down in the style sheet is overriding the one you just added. In this case, you can either go hunting for the stubborn culprit in the original CSS or try increasing the weight of your own rule by doing one of the following:

  • Increase your rule’s specificity by adding html>body to the front of your selector (in my examples above, the asterisk (*) symbol is your selector). That is to say, your modified rule becomes:

    html>body * { text-align: left; }
  • Make your rule !important by adding that text after the rule. Your modified rule, marked as important, would look like this:

    * { text-align: center !important }

According to the creators of CSS, one of their goals was to make the Web more customizable to the end user. Thanks to tools like Firefox’s Edit CSS option in the wonderful Web Developer Toolbar, this is finally an easily-achieveable reality!

Create Personal Stylesheet Preferences in Other Browsers

If you’re not using a Mozilla-based browser (why aren’t you?) and don’t have access to this extension, try writing your own style sheets with your specific display preferences in it and applying them through your browser software.

Your style sheet is just a plain text file which can be written in any text editor.

Safari on the Mac allows this by going to the Safari Menu → Preferences → click the Advanced pane → select Other… from the Style Sheet drop down menu and select your style sheet.

Internet Explorer for Windows also supports this technique but the option is a little more cleverly hidden. Go to the Tools Menu → select Internet Options… → click on Accessibility → check “Format documents using my style sheet” in the “User Style Sheet” section → click Browse and open your style sheet.

(Internet Explorer 5 for the Mac also supports this option but that browser is so bad, so old, so slow, so buggy, and so insecure that finding the option is left as an exercise to any reader who dares to still use it.)

Opera for Windows and Mac also let you choose your own style sheet. Go to Preferences (from the Opera menu on a Mac or from the Tools menu on Windows) → click Page Style in the left column → click Choose next to the text box that reads “My style sheet.”

Here’s a recommendation for what to put in your new personal style sheet. Remember, however, it’s your style sheet, so feel free to start with this but add your own preferenes as well!

/* make pages dark-on-light and use a big-enough text size */
body { background: white; color: black; font-size: medium; }
/* keep paragraphs narrow and left-justified */
p { max-width: 40em; text-align: left !important }
/* I want headings in the Times font */
h1, h2, h3, h4, h5, h6 { font-weight: bold; font-family: Times; }
/* show me what the access keys are! */
[accesskey]:after { content: "(Access key: " attr(accesskey) ")" }
/* show me which images are actually links */
a img { border: 2px solid blue; }

Try browsing the Web with your new stylesheet. I’d be very interested to hear how it goes. Which sites could you use your new preferences in without any problem? Which did you break?

Written by Meitar

October 15th, 2004 at 5:16 pm

Posted in CSS,Tech/Computing

Outsmarted again!

4 comments

I’ve been learning how to create C programs, for no real reason other than academic interest. Tonight I gave it my second shot and wrote a program that should convert your weight from pounds to kilograms. So I showed it to Danica but, as usual, she was smarter than the program I wrote:

Danica outsmarts my program by supplying unexpected input to a question about her weight.

Crap.

Written by Meitar

October 12th, 2004 at 10:51 pm

Posted in C/C++,Personal

Byebye Bug, Hello Productivity

3 comments

As expected, just sitting down and doing it led to the aforementioned bug being squashed. That seems to be the answer to almost everything these days: Just do it. (No, I actually wear New Balance.)

Also, a special note to Blondzila: thank you so much for your caring comments these past few days. I don’t really know what to say. Funks like these happen all the time. Sometimes they’re more serious and some times they’re not. Oftentimes they’re a symptom of my frustrations more so than they are of my bipolar disorder.

Over the years I’ve come to the conclusion that the more dangerous things for people like me (i.e. folks with bipolar disorder) is not really getting into funks at all. My parents and loved ones, God bless ‘em, used to be notorious for seeking out the tiniest little down I was having and begin asking me about my medications. That wasn’t really all that helpful. It often made me feel like I should’t be getting into downs at all, and funks were failures rather than obstacles.

Of course, that’s pretty ridiculous. Ups and downs are very normal; people without bipolar disorder get into funks all the time. That’s why I think the more dangerous thing is how we (folks with BPD) respond to the funks we get in.

In terms of emotional self-care, preventing unwanted feelings is far less important than responding appropriately to them. Learning to react to your own ups and downs in a way that benefits you is a skill everyone, bipolar or not, would do themselves well to learn.

I’m still learning, and it helps me to do the beneficial thing a lot when I hear the kindness and caring of people like you. So, again, thanks. :)

Written by Meitar

October 12th, 2004 at 2:12 pm

Wiki-ing About

leave a comment

You know, I can spend hours upon hours jumping from article to article on sites like Wikipedia. So far, it’s been two hours of reading up on CIDR, BGP, other various networking protocols and even learning a bit about the PSTN.

Yes, yes…sorta useless, but rather hypnotic in a strange kind of way.

Written by Meitar

October 11th, 2004 at 2:22 am

Posted in General

Site bugs.

one comment

I discovered a number of bugs in this site, which I suspect has to do with a WordPress plugin’s default CSS styles. That is, it doesn’t seem to play nice with my own stylesheet.

I should probably fix it, but I haven’t the motivation. The bug, which makes any page with a comment submission form too wide (thus producing the evil horizontal scroll-bar) doesn’t affect Safari, or any Mozilla-based browser like Netscape 7.2 or Firefox. And so I really don’t care right now. But I should probably fix it anyway. I’ll have to wait for the apathy to dissipate first, though.

Written by Meitar

October 10th, 2004 at 9:17 pm

Paupery

leave a comment

Bah. I’m feeling disgustingly useless and broke. Of course, I am broke, so that makes sense. I wish I had a better grasp of expressing feelings and emotions. It appears that understanding them, controlling them, dealing with them for myself…well, it’s an entirely different matter than writing about them.

Perhaps I should just remember not to expect great things. That way, great things can actually come.

Written by Meitar

October 10th, 2004 at 9:06 pm