Latest Posts

  1. Welcome to the World of Tomorrow!

    From TDWTF Sidebar:

    El_Heffe:
    The usage of floppy disks has declined tremendously over the years and people who are new to computers may have little or no experience with them. i never gave this any thought until recently when I was helping a co-worker with Microsoft Word.

    I noticed that she always saved files by clicking on File –> Save. So I just casually mentioned “You know, there’s another way to save files that I think is easier. Just click on the disk icon”.

    She stared at me blankly. So I pointed to the floppy disk icon. This was followed by a long pause and then she said “Oh ….. I thought that was a TV.”

    cconroy:
    Fast-forward ten years or so: Co-worker, now senior level, is explaining to a new employee how to save more efficiently. New employee says, “What’s a TV?”

  2. A IE, you never cease to amaze and surprise me!

    A relatively little known, and even less appreciated, way of doing a for loop in javascript works as follows:

    for (key in array) {
         var element = array[key];
         …
    }
    

    You might recognize this as essentially the equivalent of the foreach loop in php and other languages. It’s a very useful structure when dealing with associative arrays, or just to save yourself some typing. Unfortunately, there are some quirks with this approach. Notably, as usual, in Internet Explorer.

    While at work today I was looping through some form elements, in case the page the script would ran on had multiple forms. Though my test page only had a single form element in it, IE gave me multiple additional elements, such as the letter p, and the number 13…

    Worse still, it did the same for the form.elements array within an inner loop. I did some investigation and found that this is a bug in IE, and has been around for a while now.

    So thank you IE8, for showing us yet again that as far as you’ve come, you’re still the bottom of the proverbial browser barrel.

    Also, thank you Doug for also writing a post on this issue… albeit over 3 years ago 😛 I just felt I should share the fact that this is still very much an issue which IE has, even in its most recent version.

  3. Fun Fact #372

    Remember, Javascript, like most languages, short-circuits when dealing with if statements.

    What does that mean?

    Well for example, when running an OR evaluation with two functions, such as

    if(doThis(var1) || doThat(var2)){
         alert("Woot!");
    }

    If the first function is true, the second function will not execute.

    Something to keep in mind for future reference if you’re wondering why your function’s not running.

  4. This City is Endless

    A rough approximation of my walk today, though out of order for the purposes of Google Maps.

    E to D, train to A, Matt got onto the subway to meet Brett at B, and I walked to C for the heck of it, and then D to catch the bus, for a total of about 6 miles, not including wandering around J&R for like an hour, or the walk from 49th street, where I got off the bus, to Bryant Park.

    View Larger Map

  5. Palm Pre: First Impressions

    So I’ve had my Palm Pre for about 4 days now, replacing the dinosaur of a Motorola which I used prior, who’s screen had cracked and which crashed and froze on an almost hourly basis.

    The main appeal of the Pre, for me, was WebOS. As a web programmer, dangling the carrot of coding embedded apps with my existing skill set is a tempting one (and the same reason that I kinda liked Konfabulator/Yahoo! Widgets). But I’ll get to my experience thus far developing for it in another post.

    The physical phone itself is very nice, especially when it’s closed. It’s just satisfying to hold, and doesn’t feel bulky at all, even in your pocket. The screen is only a tiny bit smaller than the iPhone, a difference which I can more than live with, and I like having a physical keyboard. I dislike the portrait keyboard though. Every time I use it I can’t help but feel a little cramped, and I have small hands to begin with. A Landscape slider would’ve been way more comfortable. The keys themselves feel a bit too soft too. I’d have preferred harder keys, as I fear these will wear down much faster, since the portrait slider configuration means they’re smaller, and I have to hit them with my fingertips. The Ringer Off switch is great though, especially for movies and for the bus (I don’t like waking sleeping people on the express bus with my phone, I think it’s rude).

    The multi-tasking is, by far, the best part about the phone in my opinion. The ability to smoothly move to, use, and control apps feels very satisfying and almost cathartic. Synergy, which was also heavily touted, falls flat in my opinion though. Don’t get me wrong, I loved just inputting my Google account info and being done, but as others have mentioned in reviews, it imports ALL of your Google and Facebook contacts, and only merges them on name, not on other reasonable data (like screenname). For me, the biggest annoyance was that it imported my AIM buddy list, which has 200 buddies, half of which are either inactive or I no longer speak to. There’s no option to disable this either. If you sign into AIM, your buddy list is just dumped into the phone. I’ve already organized my Google contacts, and culled my AIM buddy list as a result, and I’m just not going to add my facebook account, but I’ll get to that in a second.

    You see, my primary problem with the Contacts list is the inability to organize contacts by group. So while even 7 year old phone have friends, family, etc groupings, the Pre does not, even if they exist in your Google contact list. I can only group contacts by Company, and even then, I can’t collapse that group, so I have all my former coworkers taking up tons of space at the top of my contacts list, with no way to move them out of the way or close the group if I don’t use it often. Don’t get me wrong, I could just search for my contact, but I don’t always want to have to open the keyboard to do so, especially when the fix for saving much of the room would simply require replacing the “divider” widget, with the “collapsible divider” widget. It’s literally a 2 second god damned job.

    There’s more but that’s all I really wanted to talk about at the moment. I just finished working on version 0.1 of the app I’m writing today, so I’m kinda happy about it so far. I’ll describe it a bit later on when I have some more free time.

  6. A Javascript-less Image Viewer

    So a while back, I was tasked with making what essentially boiled down to an image-viewer. The catch? I had to make it work without javascript (for Internet Explorer in particular), and it had to be done without reloading the entire page.

    Sounds weird, I know, but blame Valve for using Internet Explorer 6, sans javascript, as their HTMLView object in the Source Engine SDK. Anyway… It sounds difficult, but it’s really not, it’s actually very VERY simple, it’s just easy to overthink.

    First of all, you’re going to have to make sure all of the images are the same size, or at the very least, the same height. You’re going to block out the HTML like so:

    <div id='slideshow'>
         <img id="image1" src="imgimage1.jpg" alt="Image 1" />
         <img id="image2" src="imgimage2.jpg" alt="Image 2" />
         <img id="image3" src="imgimage3.jpg" alt="Image 3" />
         <img id="image4" src="imgimage4.jpg" alt="Image 4" />
    </div>
    <div id='slideshowNav'>
         <a href="#image1">Image 1<a>
         <a href="#image2">Image 2<a>
         <a href="#image3">Image 3<a>
         <a href="#image4">Image 4<a>
    </div>

    The key here is the fact that all of the images have their own id values. Now the css is going to look like so:

    #slideshow{
         width: Width of your widest image;
         height: Height of the images;
         overflow: hidden;
    }

    Now the end result is you have the slideshow div acting as a sort of “viewing window” through which you’re looking at the images. Each image has an id value associated with it, and clicking the link jumps to that image in the slideshow div.

    I should note that last I checked, Opera has a problem with overflow hidden and scrolling, but it’s a known bug in Opera and is in fact even a part of the Acid2 test, so I believe Opera 10 should work fine with this trick.

  7. The Impossible Octal

    Hehe, here’s a little trick I learned from TDWTF… Thought it’s really less of a trick, and more of an “I can’t believe it’s that broken” moment.

    In the title bar of your browser, add this:

    javascript: alert(parseInt('05'));

    You get 5, right?
    Good.
    Now try this:

    javascript: alert(parseInt('09'));

    Yup, that’s right, you get a 0.

    Here’s the article with the explanation for this odd output:

    If you guessed 9, you fail. No, it’s zero. See, Javascript supports octal numbers. Any number starting with a zero is octal, even if it can’t be an actual octal number. In certain languages, like Perl, trying to use a non-octal number as an octal number results in an error. In other languages, like Javascript, it silently fails.

    So, thank you Javascript, for teaching me something I didn’t know about you… and making me hate your quirks all the more.

  8. Blogger RSS feeds by tag (aka label)

    One thing I wanted to do was have RSS feeds by tag/labels back when I used to use Blogger, so that I can use a single blog for the journal, and tips sections of the old site. The url for a specific label in a feed is:

    http://yourusername.blogspot.com/feeds/posts/default/-/tag1

    If you want to use multiple labels (this one, for example is labelled as ‘tips’ and ‘other’), just add the tag to the end of the url, like so:

    http://yourusername.blogspot.com/feeds/posts/default/-/tag1/tag2

    This will return all posts which are both tag1 and tag2.

  9. URL file access with a cURL backup

    So in the process of getting my website up and running, I ran into the ‘URL file-access is disabled in the server configuration’ message. Since the server admin was asleep, I figured I’d try to find a workaround. cURL is a commonly used one for this scenario, but the problem is that if you switch hosts it may not be available. As such, here’s a handy variable to tell if URL file access is enabled:

    ini_get('allow_url_fopen')

    It returns true or false depending on the value in the php.ini file, and you can throw it in an if statement to test for it, and use cURL in the else statement in case it fails.

  10. Valid Blogger RSS Output

    Having trouble getting your blogger rss output to validate because Google botched the tracking code (lack of alt attribute in the tracking image)?

    Do what I did, add this to the php page processing the rss feed:

    $entry['content'] = substr($entry['content'], 0, -8) . " alt='' />";
    

    This cuts out the closing img and div tag, adds alt, and closes it all again… just pray google doesn’t change it >.>