E-com DevBlog Spider-ball-vacuum

29May/080

Automatic FTP

automatic-ftp

A few weeks ago I was looking for a way to automate downloading thousands of files from an ftp site, I figured using php would be sufficient since that is what the site I was working with used. I tried google and some of the better php sites but to no avail. So I found some code that was similar to what I wanted and tweaked (and by tweaked i mean almost completely rewrote) it to suit my needs. Now I'm not claiming to be a php genius (or any kind of genius for that matter) but I'm pretty impressed with what I came up with. In a nutshell what this code does is open up a mysql session and an ftp session to a remote server, then it runs a query in the mysql database to create an array for php to use. Then it loops through each item in the array and checks with the remote ftp server for the file, updates to that file (time based), and if the file matches a certain size to be ignored.
This turned out to be quite handy because by the time I was done I could modify the code slightly and search in different locations on the server as well as store the files on a different spot on my local machine.
To test this I ran a 13k item array through this script and it was quite flawless...took about 3.5 hours to run but that's still way faster than downloading by hand even if you include the time it took to write the script.

So I decided to share this script since i couldn't find one myself, feel free to modify it in any way, if you find a way to make it better, more efficient or even hyperthread the downloads I'd like to know so please send an email with the code. Just make sure something like ftpgrabber is in the subject line...otherwise you'll get deleted as spam er somethin'.

Download ftpgrabber

Print This Post Print This Post
29May/081

Awesome Image Evolution

awesome-image-evolution

So a while back, and by a while I mean about 3 months or so ago Marketing decided they'd like to show some eye catching images on some of the products on two of our sites...lucky me I got this task and at the time accomplished this the only way I could think of (and I'm not sure why it's the only thing I could think of). What I did was use Field 4 as a place holder for a phrase/word that would trigger an image to be shown if a proper word/phrase was in that field. The code looked quite similar to the following:

?View Code HTML4STRICT
<wcbase:useBean id="product" classname="com.ibm.commerce.catalog.beans.ProductDataBean" scope="request" />
 
<c:if test "${product.field4 == 'blah'}">
     <img src="blah"/>
</c:if>

While functional and handy for keeping any rougue phrases from triggering a false image this is not ideal, especially when your marketing group keeps adding more and more images to display...I think now we are up to around 8.
So about a month or so ago Phil got a task to add yet another image and while consulting about it we decided it would be better to change the code so that there weren't so many if's in our code. So we chaged it to the following:

?View Code HTML4STRICT
<wcbase:useBean id="product" classname="com.ibm.commerce.catalog.beans.ProductDataBean" scope="request" />
 
<c:if test="${product.field4 != ''}">
     <img src="<c:out value="${jspStoreImgDir}${product.field4}"/>.jpg" alt="<c:out value="${product.field4}"/>" />
</c:if>

This is much better because it allows us to put any value in field4 and then the code will strip that value and slap a .jpg on the end, so as long as we have a value.jpg image it will show up. However we did find a bug in this, apparently if you have had a value in field4 and deleted said value it confuses the code and websphere will still look for a .jpg image which of course is nowhere to be found, and if viewed in the wrong browser (ie IE) a missing image will appear (funny how missing images can appear). So recently we've changed this code yet again and this time I think we nailed it, have a look:

?View Code HTML4STRICT
<wcbase:useBean id="product" classname="com.ibm.commerce.catalog.beans.ProductDataBean" scope="request" />
 
<c:if test="${!empty product.field4}">
     <img src="<c:out value="${jspStoreImgDir}${product.field4}"/>.jpg" alt="<c:out value="${product.field4}"/>" />
</c:if>

The empty seems to ignore any previously entered values and focus on the fact that the field is empty and not so much look for a null value.

THE END

Print This Post Print This Post
28May/080

Limelight recieved an update

limelight-recieved-an-update

Today I had to change out some of our cached content, and wouldn't you know it, limelight has upgraded their website (it sure looks nice, but now requests take 10-30 minutes instead of 45 seconds :( ).  Anyway, I figured that I would go ahead and make an update post with the instructions on how to clear an image/page.

Login in to Limelight

1 - To use limelight, you still go to the same place, http://reports.llnw.com/. You'll probably notice that the login page looks much nicer than before, and we still use the same username/pass to get in, so if you forgot what it is then check with Ninja, Brett, Brandon, Brett/Burt, or me.

the main page after logging into limelight

2 - When you log in, you get dumped at this empty page... click on "Tools" in the upper right corner of the screen.

the Purge List of limelight

3 - And here is our purge list.  Much nicer to look at, and it's been ajax'd!  You can sort through requests (although there are not many listed right now ;) ) but more importantly, you can click on the tiny "Add Request" link on the upper right side (next to the 'Search' box).

the submit purge request page of limelight

4 - The submit is pretty self explanitory, although make sure that you click the drop-down menu on the top left and pick a "ShortName", if you don't you'll just get errors when you try to submit your purge request.  After you have picked a name, type in the url you want cleared (you can either use the limelight address (images.whatever.com) or the standard 3dubs (www.whatever.com).   Then if you want a confirmation email fill out the bottom form, otherwise click on the "Submit Request" button.  You'll then hit a re-direct that dumps you back at the reports page.

5 - Wait 10 - 40 minutes... seriously... I'm not kidding, and if you think I am, check out those request times in the screen shot (the requested vs. completed columns).

Print This Post Print This Post
28May/081

httpSpy for Firefox!

httpspy-for-firefox

This morning I stumbled onto a real treat for those developers that are using Firefox.  Backstory: A while ago Ninja had suggested that we use a little program called "httpSpy" for debuging the header information that was being served/requested by our server/browser (very useful to find obscured links, what items are really being loaded on a page, and what connections are being secured).  The problem is that while the program is awesome (and extremely hard to find as there are 3 or 4 variants on a google search that are all different), it only works with IE.  Naturally, this is undoubtedly causing a shudder and a distinct feeling of betrayal to surge up from the depths of your soul ;) .  The time of IE only debugging is at an end...  Introducing "Live HTTP headers", a fantastic little tool that pops up in a different window that will show you your requests and let you resend them ( with some modifications) and logs everything being passed to and from the server/browser.  While I haven't really played with it for more than a few minutes, it seems like a good tool, and I'd recommend throwing it in the arsenal.

Live HTTP headers - can be downloaded here (link goes to the mozilla add-on site, as I did not grab the xpi file). It also works with FFox3RC1 :twisted: .

Print This Post Print This Post
21May/080

IE Hompage reset (Part 2)

ie-hompage-reset-part-2

Originally I had entered this information in the original post, but I felt that it needed it's own post (the video limitations of the plugin's that I'm using to display video also prompted this second post ;) ).

Anyway, Remo commented (in an email) about using the Group Policy Editor (gpedit) to change your group policy restrictions to change your homepage (yes you can do that and a ton of other things that you can play with), this is another viable route to the homepage lockdown problem, but he also asked for a post on using regedit to unlock or change your homepage. I thought that maybe I would find the key that actually holds the homepage information and just edit that, but I found a different way that I think I like better (seems like it has less potential for system-wide destruction). So here are the steps.

  1. Crack open regedit from the command line
  2. when this opens navigate/drill-down to
    "HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet
    Explorer\Control Panel". Note that this will only exist if your current
    admin has locked down your computer... if you can't find this route
    (meaning this tree does not exist) then DO NOT CONTINUE!
  3. If you did find the path, then now is the time to make a backup of
    your registry file. To do this click on File->export->(make sure
    your selected branch is at the bottom, or click "All" for the entire
    registry) Save.
  4. Now that you're safely backed up, lets double-click on "HomePage"
    (it's the blue REG_DWORD value in the right pane). In the pop-up change
    the value from 1 to 0, and viola! crack open IE and go to change your
    homepage the "normal" way and it will no longer be locked.
  5. rejoice in your geekery...(not a required step, but it is recommended :) )

[display_podcast]

Print This Post Print This Post
20May/086

gzip/deflate – a (fairly) quick how-to for XAMPP

gzipdeflate-a-fairly-quick-how-to-for-xampp

I've spent a little while trying to figure out the difference between using "deflate" and "gzip" for web-compression.  What I've finally ended up with is they are pretty much the same thing (well they use different compression methods, but seriously, they do just about the same thing).  I also noticed that if you are running Apache 1.3 your compression options pretty much are gzip, and if you are running Apache 2 you pretty much only have deflate.

I searched all over for someone who knew how to set this up so I could have it on my local dev box (I'm currently running one of the XAMPP packages).  I didn't find the answer anywhere, what I did find was plenty of people telling me to create a .htaccess file and everything should be good.  Or links to the Apache documentation on using deflate (which while helpful, is pretty much a standard doc... so-so in the "I'm not really sure what I'm doing" department).  Believe it or not I found the answer in the depths of a linux tutorial site.  So I'm posting the run down in case you want to play with compression on your own site.

  1. You need to make sure that you have the mod_deflate plug-in enabled on your web server.  For XAMPP users this is found in the /xampp/apache/conf/httpd.conf file.  Mine was actually on line 93 of the file, it was there, just commented out (with a #) so I took off the comment and now the line reads "LoadModule deflate_module modules/mod_deflate.so"
  2. Now you need to restart your web server
  3. Let make (or modify) a .htaccess file. To enable the compression you need to add this to your .htaccess file.
       SetOutputFilter DEFLATE
    
  4. Make another .htaccess file in your js directory (or just tack on another 'Files' tag) and replace the "*.html" with a "*.js". That will enable compression on your js files (Also noted that if you used a packer (like the excellent dean-edwards packer) this might screw up your script or cause your page not to load. The best idea for js compression is to minify it and then use this deflate or gzip compression on it. (see a previous post about js compression to find links :) )
  5. And you're done. Seriously, that's it. It's that simple. Why no one on the net had posted that is beyond me. You should now be done and you can go and check your work by cracking open a page on your web server and checking the page size. The easiest way to do that is to use the Firefox Web Developer Add-on and click on the "Information" button then click on "View Document Size".

So for my own site (a webapp called the WebTop) here is what I ended up with.  Without deflate compression enabled my page was 134k, with a massive 94k of that being various js files. and 17k being chewed up in html files.

Document Size without deflate compression

With the compression turned on however, we managed a very acceptable 56k for the site.  The html being compressed down to 4k, and the js files being crunched down to 29k.

Document size with deflate compression

Print This Post Print This Post
20May/081

FF3 RC1 – WebDev add-on is go!

ff3-rc1-webdev-add-on-is-go

As you may or may not know, yesterday I updated my portable copy of FF3b5 to the RC1 release... unfortunatly it upgraded my version 2 and my standalone 3b5.  So I lost most of my plugins, and was rather hosed.  Good news however, my FireFox informed me this morning that it had found an update to one of my add-ons (I actually like this new feature of FFox checking for updates for me, it's kind of nice).  It turns out that the team that developed the webdev toolbar had released a new version of their tool, and it's FFox3 compatible!  So now I have the latest FFox and most of my missing tools! (I grabbed the firebug beta from getfirebug.com - it's a little flakey so it's nice to have the webdev bar back).  There are a few other plug-ins that work right now as well (like ie-tab).  Anyway, just thought I'd let you guys know that it's out there and ready to go in case you wanted to update to RC1 (or did accidentally)...

Print This Post Print This Post
Tagged as: , , , 1 Comment
19May/080

A little Homepage reset in IE

Sounds easy enough right?  Well what happens when your box has been locked down and when you look at your internet options in IE (or in control panel) you discover that the homepage box has been grayed-out and there's nothing you can do to reset it?  Simple, use another route.  One of the things that m$ almost got right was the ability to get anywhere you wanted to by at least 2 different ways.  In this case the SysAdmins may have blocked your normal route with a group or user policy, but they didn't block the other route.

[display_podcast]

If you just watched the video (sorry about the small compression)  you've see that there is another way to set your homepage in IE7, the little drop down menu by your homepage button.  simply navigate to the page you want as your homepage and then click the drop down and select "Add or Change Home Page".  From there a new dialog window will appear and then click on the radio button next to "Use this webpage as your only home page" (the first time you do this I think you have three options so pick the one closest to this option).  From there just click the "Yes" button and then you're set!

Print This Post Print This Post
19May/080

Team Awesome – The Theme Song

This has really nothing to do with development, but our team ("Team Awesome") has finally got a theme song, and I decided to share that with everyone.

Team Awesome - Rock'd Solid Mix

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Team Awesome - Drew's Lightweight Server Mix

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

enjoy!

Print This Post Print This Post
16May/080

FFox broken image plug in

Update: Brett/Burt has had a problem with this working on his box, so it may not be compatible with some plugins/add-ons.

One of the worst things that I run into is the prettifying that FireFox routinely does to webpages. When you surf, it's a great idea, who likes to see broken image files? But when you are developing it gets in the way and can take an otherwise smashing page, and make it look... uh... well smashed. To get around this issue you used to have to install "greasemonkey" and then grab a user-script in order to force firefox into showing you broken image files. Well luckily those days are over as the other of the original script finally made it a standalone plug in. You can grab the plug in here.

I decided to do a little testing between FF2 (with the plug-in), FF3b5 (w/o plug-in), and a control IE7 (yes using IE7 as a control actually made me cringe, and may have given me a rash). I then created a generic html page with 6 broken img links in it. Here's what we have:

  Broken image
  
   image
  Broken 
   
   

Now as you can see, I have some invalid html (missing alt tag), a couple alt tags with spaces, a few with the alt tags as spaces, you know some ugly things you should never do, and yet we find all the time. Render Time!! Let's start off with our control.
IE rendering the broken html page

Here's how FF3b5(w/o plugin) rendered this mess:
FireFox 3 beta 5 w/o plug-in rendering a broken html page.
Notice that it shows up with alt tags showing, and at first glance it looks like it picked up 4 of the 6 images. Upon closer inspection though, you'll see it only saw 3 and prettified the page by removing the rest. Although I gotta say, seeing the alt text looking so plain really throws me off when I'm looking for where an image should be.

And lastly a render with FF2(with plug-in)
FF2 with plug-in rendering a broken html page
We can see exactly what the plug in did. It doesn't show the alt text now, but you at least know that there should be *something* showing up on the page. When it's all said and done, I'd say that this is worth the install, and quite a nice plug in.

Print This Post Print This Post