Yearly Archives: 2005

Using AJAX to prefetch large files

I have been thinking of how to increase perceived performance for web
apps lately and came up with a nice (and simple) optimization for large files.  I’ll
use an image gallery as a conceptual way to get my point across.  I’m
not currently aware of any image galleries that do this, but I think it
would improve the user experience.  Most (if not all) image galleries
have a main interface involving multiple pages of images.  For this
example, we’ll consider that the user is currently viewing page 1.  The
basic premise is that by using AJAX, we’ll load the images for page 2
into a hidden div on the page.  The main reason for using ajax is so
that we can do all of the prefetching after the page has finished
loading.  That way, we don’t hurt the performance of the visible page
in any way.  The browser will cache the images and when the user
decides to view page 2, the images will not have to be re-downloaded.

For this example, I will use the prototype javascript library to handle
some of the details of the AJAX request, etc.  If you prefer to use
your own library to accomplish the same thing, you wont hurt my
feelings 🙂  Also, keep in mind that this is just a proof of concept and could be modified for much more complex use cases. 

In order to allow the current page to be downloaded and processed as
normal, I hook the load event for the current window.  This gets fired
after the page has finished loading, so the user will be able to view
and interact with the page before we make the AJAX request to get the
next group of pictures.  The result is that downloading the pictures for the next page in the gallery is transparent and doesn’t affect the user experience.

    <script language=”javascript” type=”text/javascript”>

        function PreLoadImages()
        {
            new Ajax.Updater(‘LoadImagesHolder’, ‘/GetImagesService.aspx?PageId=2’,  {asynchronous:true});
        }

        Event.observe(window, ‘load’, function() { PreLoadImages()});
    </script>

The html that gets returned from GetImageService.aspx is essentially just <img> tags.  The previous code block inserts the returned html into a div with an ID of LoadImagesHolder:

    <div id=”LoadImagesHolder” name=”LoadImagesHolder” style=”display:none;” > </div>

So putting it all together, the main page would look like the following.  For sake of space, I omitted the main html representing the image gallery.

<html>
<head>
    <script src=”prototype.js” type=”text/javascript”></script>

    <script language=”javascript” type=”text/javascript”>

        function PreLoadImages()
        {
            new Ajax.Updater(‘LoadImagesHolder’, ‘/GetImagesService.aspx?PageId=2’,  {asynchronous:true});
        }

        Event.observe(window, ‘load’, function() { PreLoadImages()});
    </script>
</head>
<body>

<!—  *****************
      ** The main image gallery html would go here
      ***************** —>

    <div id=”LoadImagesHolder” name=”LoadImagesHolder” style=”display:none;” > </div>
</body>
</html>

The other hidden bonus to this method is that it works with all browsers that support AJAX. 
I have tested and verified it with Firefox 1.x and IE 6.x.  So anyway, I hope this helps someone make the web seem faster.

My dotcom predictions for 2006

Fun… According to this, these are my 2006 predictions:

Last year I made several predictions that now seem ridiculously round.
But a few ideas were pretty close. I’ve got a feeling that 2006 will be
a big year, and here are some of the reasons why:

  1. A Mt View startup is going to open our eyes to some new ways that
    XUL can influence culture. Make will pick up on this and run several
    cover stories on the founders.
  2. martin fowler will be in the spotlight for his decision to
    support xml. This will upset Riding Rails, and the blogosphere will
    react funkily. The noise will quiet before the end of the year and it
    will all be forgotten soon after the shock.
  3. ebay will see their stock skyrocket after their online
    auction business starts taking off. We’ve seen it coming for a while
    now, but 2006 will be the year it really kicks into gear.
  4. Either google or yahoo will seek to expand their paid online
    advertising business by acquiring 37signals. FM Media will be
    overlooked in the process, and they will see a management shakeout
    later in the year.
  5. One of the big leaders in the pencil manufacturing industry
    will wake up to the opportunity in the Internet and the Web 2.0 trends.
    After months of speculation, they will make a key acquisition that will
    shake up the landscape for years to come.

Setting up a LLC in Wisconsin

I setup a LLC this past year and after seeing this article for Illinois, I figured it would be worth describing the steps for how to set up a Limited Liability Company in Wisconsin.  I am not a lawyer and I’m just providing this as information.  Please consult a lawyer and or a CPA before following these steps.

  1. For a good starting point, it’s worth looking through the docs on this site.
  2. File an Articles of Organization (Chapter 183) with the Wisconsin Department of Financial Institutions.  I did mine using an online form and it only cost $130.
  3. After that has been processed, it was determined that I should get an Employer ID Number (aka. EIN or Tax ID #).  Among other things, this is so that I could open a bank account in the name of the business.  Again, I used an online form (SS-4) to get my EIN.
  4. There are several options for the entity type with common options including sole proprietorship, disregarded entity, or partnership.  Again, it’s worth asking your CPA or lawyer for their advice on that.
  5. Now I opened my bank account for the business.  In general, banks require the Articles of Organization and EIN in order to open up an account.

That about sums it up.  After all of that is taken care of, it’s time to work on generating some income 🙂

Why bird poop is white

In an effort to broaden my post categories….

I was talking with a very wise friend of mine a while ago and we got on
the subject of why bird poop is white.  He started off describing
that humans have one of the most inefficient bodily waste
systems.  We have seperate functions for excreting liquid and
solid waste… As a result, our kidneys excrete nitrogenous wastes as urea which ends up getting dissolved in urine… 

On the other hand birds are unable to urinate so their kidneys excrete
nitrogenous wastes in the form of uric acid.  Uric acid has a low
solubility with water, so it comes out as a white paste.  Combine
that white paste with some intestinal output and you get white bird
poop sprinkled with little black bits. 

My approach to dating….

I can’t help but think that the way I approach people has changed in
the last year or two.  I rarely think of various people as my
superior… I respect people who deserve it, but I will not bow down to
someone just because they hold a title.

Along those lines, I have come to an enlightenment of sorts with how I
approach girls these days… Rather than try to approach them in an
effort to just have sex, I’ve changed to where I approach them as if I
were their friend.  I find this approach works much better
overall.  Getting my drunken self to follow this logic is another
thing entirely, though 🙂

Art of software development

I just got out of a 5 hour meeting with the owner of the company that I
work for.  Among many discussions, we had one about the art of
coding.  The current mindset is that people who work with software
should be treated the same as people who stamp widgets.  By that,
I mean that they should be expected to work 8-4:30 and put in overtime
if you’re behind schedule.  What we tried explaining was that it
actually hurts performance if you force software developers to work
more hours (without pay).  If you give them more freedom in hours,
the chances are pretty good that they’ll end up working more than 40
hours anyway. 

But we came to a conclusion that working on software is similar to
writing music.  Sometimes you’re just in a zone and are very
creative.  Other times, you’re not.  Putting in more time
doesn’t necessarily mean that you’ll get that much of a return. 
In fact, it could work against you.

So through that, we realized the value of a product plan.  With a
product plan, you’re accountable for features, etc by certain days…
If you get them done, great.  If not, then you put in extra time
to get them done.  All without forcing hours or anything.

My future with web development

Lately, I’ve been feeling like I am digging myself into a shallow
hole.  I feel that I am locking myself into a boring couple of
years of asp.net development.  No offense to anyone, but asp.net
has really lost steam for me.  Even with the recent release of
asp.net 2.0, I feel myself wanting to drift to another
language/platform.  Asp.net has just lost a lot of true innovation
and watching MS time after time ignore community software is really
getting to me.  If I were to pick a platform right now, I could
pick Ruby On Rails.  There is such an amazing buzz around that
language and framework, that it reminds me of the excitement that the
internet used to have.  Extremely rapid development giving anyone
with an idea a shot at making a virtual (and possibly physical) impact.

So why not dig myself out of the MS hole and start developing with
RoR?  Well, there are a couple issues that I need to tackle before
I can venture down that path.  First, RoR isn’t optimal on the
Windoze platform. Overall, this is fine by me, but I don’t have a lot
of time to learn how to configure Apache on a unix variant. 
Second, I have some personal projects that are eating up every waking
moment for me.  These projects are important to me and have a
substantial code base, so porting them to RoR wouldn’t make sense at
this point.  I’ll have to wait till I have a stable version of
each project until I can port them.  Finally, my knowledge with
asp.net and c# is much greater than RoR.  Taking the time to ramp
up to coding techniques/syntax of Ruby is something that I cannot
afford at this time.  Again, when my personal projects have hit a
stable version, I will take the hit and learn Ruby more thoroughly.

If you’re curious what prompted this short rant, I can answer that in
two words… Visual Studio.  I cannot tell you how much I despise
that piece of software.  I am jealous when I look at how simple
and STABLE TextMate is.

So my ideal course of action is to get a working copy of OSX (either
buy a power mac or get the osx86 dvd) and start developing under that
OS.