Awesome PHP debugging function

I still haven’t found a good free setup for debugging PHP but this is the next best thing. Jacob Rosenberg posted a copy of his yo() debugging function. We used it extensively when building http://video.yahoo.com and I can vouch for its awesomeness.

The Greatest PHP Debugging Function of All Time.

I did have one issue with it though, for whatever reason the install of PHP on my DreamHost account wasn’t ever able to pick up any vars if I used the yo() shortcut. I had to modify the shortcut so that it passed func_get_args() to the static function. Weird, and annoying that everything was now wrapped in a superfluous Array() but not the end of the world.

I’m happy to have yo() available to me again for what little PHP work I do these days. It makes me feel warm and safe.

YUI 2.8 Uploader

I know this is old but I finally tried upgrading my uploader implementation at http://tivac.com/upload/ to YUI 2.8. Ran into some nasty problems where the SWF would never fire its contentReady event.

Turns out, it’s a known issue with the Uploader component in YUI 2.8 and it’ll be fixed in the next patch release.

Important Issue: Due to a current bug, the current version of uploader.swf hosted on yui.yahooapis.com in the YUI 2.8 branch is NOT compatible with the uploader.js hosted on yui.yahooapis.com. Until the next bugfix release, you can work around this issue by either locally hosting the older version of uploader.swf (available here), or locally hosting the uploader.js and making the following changes to it:

  • On line 509, in swfObj.addVariable(“elementID”, swfID);, replace “elementID” with “YUISwfId”.
  • On line 512, in swfObj.addVariable(“eventHandler”, “YAHOO.widget.FlashAdapter.eventHandler”);, replace “eventHandler” with “YUIBridgeCallback”.

That only had me frustrated for 5 minutes, thank god I read the documentation.

Windows 7 Explorer Jump List Pinned Items

I’ve been using Windows 7 since the first public builds came out and it’s really fantastic. The new taskbar is great and the ability to pin items to jump lists is super-useful. Instead of making a bunch of shortcuts in the start menu like in Vista I just pin all the folders I access constantly to the Explorer item on my taskbar.

I was doing some experiments around storing my Users\Tivac\Videos folder on my WHS box by using the “Change Location” feature in Windows to point it at \\SERVEBOT\Videos. It works ok, though I’m not 100% happy with the outcome. Since I don’t have my local computer keeping an offline copy the icon changes, and until WHS PP3 comes out my video library is unsearchable. During the experiments I changed the Videos folder location a few times, and eventually the “TV Shows” & “Movies” folders ended up pointing to invalid UNC locations.

For whatever reason, after that point I was totally unable to remove those items. Clicking them would bring up a “This item doesn’t exist, do you want to remove it?” prompt but it didn’t do anything. Right-clicking and choosing to unpin the shortcuts wouldn’t do anything. Clicking on the little pin on the far right of each when you hover over them? Nothing. I was starting to get really annoyed by the two broken shortcuts I couldn’t do anything about.

Some searching finally led me to a solution: CCleaner. The latest version includes support for cleaning the Jump List “Recent” section but due to an oversight in the rule will also remove your pinned items. I installed it & ran it in “Analyze” mode to see what files it found and discovered that Windows 7 stores the pinned recent items & shortcuts in %APPDATA%\Microsoft\Windows\Recent\CustomDestinations (presumably Pinned items) and %APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations (recent items). Note that both of these are guesses, because all of the files in the folders look like

1b4dd67f29cb1962.automaticDestinations-ms
241b89efbfdc28ac.customDestinations-ms

and aren’t text. Opening them in a hex editor also didn’t produce anything meaningful. I’ve done some trawling around looking for answers as to what file type this really is & how to modify it but nothing helpful came up. Fortunately, my problem of stuck pinned jump list items was fixed by using CCleaner to clean out all of the files in both the CustomDestinations & AutomaticDestinations folders. I had to rebuild my list of pinned items from scratch but at least they’re all valid links again!

Arena.net

While I don’t work on the team responsible for the Arena.net site I help out all over the company wherever I can. When it was decided that the old site needed to be updated I got the call. After some discussions around what exactly the site should encompass it came down to wanting to have the site be an aggregator of updates by arena.net on various different services.

Here’s the rundown:

I certainly wasn’t looking forward to building parsers for the multiple different feed types that entails, but YQL came along and saved the day again. I only had to do simple things manually like make sure that Twitter links & @username replies were properly wrappped in <a> tags. To keep from bashing on YQL every time the page is loaded it stores the transformed results of the updates for an hour in a local APC cache. This provided the best of both worlds and made caching super-easy.

The site itself was built using YUI grids, YUI 3b1, and DD_belatedPNG to solve transparent PNG issues in IE6. It’s also using my favorite new PHP framework, Nice Dog. It’s a nano framework (about 100 lines) that is more of a VC than MVC. For a site like Arena.net it’s perfect as there’s no need for models. I could’ve plugged in an ORM to make it the full stack but when getting all your data is as simple as

apc_fetch($key);

the need to build a “proper” MVC site kinda isn’t there any longer.

PatCavit.com

Sunday morning I had a few too many skittles after waking up and decided I wanted to build an actual landing page on patcavit.com

So then I started on it, I had grand plans. There were even icons that I was going to grab from… somewhere. That part of it was rather poorly planned. After doing the basic layout I spent about an hour trying to find the right icons. Eventually I threw up my hands and just dropped the whole idea.

Here’s what I’d planned for it to look like:
052520091392.jpg

Notice my awesome hand-drawn icons… :(

Today I was feeling more up for a challenge though. I did some reading and decided to use YQL thanks to Chris Heilmann’s screencast illustrating how he used it to pull multiple sources of data together. After deciding to just ditch the icons I picked a few colors for the top-level sections instead, and here’s what I came up with.

patcavit.com.png

I like it well enough. Still wish I could’ve found icons I was happy with.

YUI Uploader Updated

The uploader I wrote and talked about in YUI Upload Implementation has been updated to work with YUI 2.6.0 and also with the new Flash security rules for browsing files. The changes were relatively minor, but here’s a quick explanation.

A new element had to be added that could overlay the button that lets you select files. Once the JS fires it makes that element the exact same size/position of the button you can see and then the YUI Upload fills that overlay with a flash object. While the button still exists when you click the event is actually captured by the flash object. This gets around the tighter flash security rules while not changing the upload experience at all. It’s not a perfect solution but at least the uploader works again.

Changed code looks like this in upload.js

var button = YUD.getRegion('browse');
var overlay = YUD.get('btn_overlay');
YUD.setStyle(overlay, 'width', button.right - button.left + "px");
YUD.setStyle(overlay, 'height', button.bottom - button.top + "px");
YUD.setStyle(overlay, 'top', button.top + "px");
YUD.setStyle(overlay, 'left', button.left + "px");
this.uploader = new YAHOO.widget.Uploader('btn_overlay');

Updated uploader still lives at http://tivac.com/upload/

Xbox Friends server component updated

I did an in-place upgrade of the server component for the Xbox Friends Gadget that should make counts of online users more accurate. I meant to do this in 1.3 and just forgot about it. Phantom friends have been driving me crazy lately, so hopefully this quiets that down. Seems to be working well so far.

You don’t need to download a new version of the gadget to get this update, it will just start getting more accurate.

Xbox Live Friends 1.3

In a fit of inspiration I’ve updated the xbox live friends gadget with offline friends and hopefully taken care of the phantom friend problem in a more thorough way. Also went ahead and added a refresh button because two minutes is apparently too much time for some people to wait.

Pictures!

You know what time it is!

Download the gadget

Quick Vista Gadget Development Note

This is more of a reminder for me than anything else, but since I kept searching for this tonight with little luck maybe somebody else will get some use out of it.

When developing a Vista gadget it can be realy useful to set up a gadget folder somewhere other than “%userprofile%\appdata\local\microsoft\windows sidebar\gadgets”. Unfortunately to have the sidebar notice it you’ll need to symlink it. That’s a pretty easy process, and note that just making a shortcut to the folder WON’T WORK.

  1. Open an explorer window to %userprofile%\appdata\local\microsoft\windows sidebar\gadgets
  2. Open a cmd prompt with elevated privileges (start, “cmd”, shift right-click, run as admin)
  3. cd in cmd to %userprofile%\appdata\local\microsoft\windows sidebar\gadgets
  4. mklink /D "Gadget Name.gadget" "c:\path\to\development gadget"

That’ll set up a symlink so you can edit your gadget wherever you want and still have Vista add it to the gadget browser. Handy for those of us that like having all our programming projects in one spot.

Tweaking the Image Uploader

For fun I went trolling through the images people have uploaded via the YUI Uploader implementation I wrote a while ago. When it took my browser a solid 30 seconds to even be remotely responsive and start rendering images it struck me that perhaps it was time to paginate the images instead of just dumping them all out onto one page.

So I added pagination. It’s currently super simple which makes for easy explanation. The PHP still collects and sorts every single image in the directory by date. I don’t think there’s any other way to do that. Afterwards it checks to see if the “o” query param was set and is an integer (thanks for adding filter_input to PHP5, PHP devs!). Once there’s an offset to start from, it slices the array at that point and takes the next 50 images.

After that there’s just some simple logic around drawing the pagination numbers and figuring out which one is the current page. The numbers are centered and boxed using a variation on Hedger’s inline-block work (Item List Grid : Practice with display:inline block across browsers) that I worked on for the next VYC release. It solves the problem with a minimum amount of code in a really semantic way that just makes my web developer brain as happy as can be. Granted the CSS is not what I would call “pretty” but it works everywhere and is not impossible to understand, so I’m not too bothered by it.

So here’s how it turned out. Be forewarned that I don’t control what is uploaded here, and as such there might be NSFW content on this page!

http://tivac.com/upload/images/