HOW-TO: use jQuery to show latest Picasa thumbnails

Why post pictures of myself when I can post pictures of my son?  He's much more adorable, trust me.  Since I'm lazy I don't want to upload the same files to my blog that have already been organized and published to his photo stream in Picasa.  The work has already been done, so I should be able to to query the Picasa stream and with some simple jQuery code, the magic can all happen in the client-side browser.

We can use the getJSON jquery method for retrieving a lot of google data across many google products.  Picasa (Google's answer to Flickr or other photo stream sites) exposes its own flavor of the familiar gData interface.  By building a URI that corresponds to a particular photo album, it's easy to display the thumbnails from a few recent pictures in the album.

 

http://picasaweb.google.com/data/feed/api/user/lkostoulakos/albumid/52601673040050129/?kind=photo&access=public&alt=json&callback=?

 

Note that the format we're requesting the data in is json and we need to include the callback=? option in order to avoid getting cross-site scripting errors.  Calling the getJSON method with your URL and a callback function is all that remains.  There are three thumbnail sizes available in the media$group object, in this example I'm using the "medium" sized image.

$j = jQuery.noConflict();                
$j(document).ready(function(){            
$j.getJSON([YOUR URL HERE],
function(data){
var thumbCount = 3;
var smallThumb = 0;
var mediumThumb = 1;
var largeThumb = 2;
var picsCount = data.feed.entry.length - 1;                  
for (var i = picsCount; i > picsCount - thumbCount; i--) {                    
var pic = data.feed.entry[i];                    
$j("").attr("src", pic.media$group.media$thumbnail[mediumThumb].url).attr("alt", pic.summary.$t).appendTo("#pics");                     
}
});   
}); 
Full source code can be found here. Enjoy!


HOW-TO: Check SQL Server Database Mail & Start Service

Because the database mail service is disabled after 10 minutes by default in SQL Server 2005, you may want to run this script to check if the service is enabled, and if not, start it.
IF NOT EXISTS 
(SELECT 1 FROM msdb.sys.service_queues
WHERE name = N'ExternalMailQueue' AND is_receive_enabled = 1)
EXEC msdb.dbo.sysmail_start_sp


Thank You BlogEngine & ASP.NET Starter Kits

Turns out that it is possible to upgrade your entire website in about 24 hours.  I have BlogEngine 1.4.5 and the ASP.NET Time Tracker starter kit to thank.

pureVirtual.biz was originally built as a few static HTML pages about 6 years ago.  About three years after that I deployed the site as a .NET 2.0 web site, but the content was simply ported over to the new environment.  There was nothing really dynamic or compelling about the features.  I always said I'd polish up the site a bit when I "had some free time."  

My goals were to add some blog features, dynamic content management and my client time-tracking and invoicing features into the site with a SQL Server 2005 back-end.  The SQL Server was included in my GoDaddy hosting account, so why not put it to work?  Up until now my invoicing and time tracking were built as custom applications, both windows forms, locally run web apps and even some Excel spreadsheets...typical home grown junk, but it worked so there wasn't much motivation to change it.

I settled on this ASP.NET (now SQL 2005 Express) starter kit for tracking my billable hours.  I knew that with a few customizations I could integrate my invoice rules and specific project information with relative ease.  The foundation for the new pureVirtual.biz is BlogEngine 1.4.5.  This open source project, built on .NET 2.0, features an amazing engine for simply deploying and customizing your own blog.  I was able to cross several items off of my wish list including (obviously) blog features and dynamic content management.  I can build and manage "Pages" separately from blog posts all without needing to redeploy the site.  Just login as an administrator and you're good to go.  Also, BlogEngine supports database integration (SQL Server or MySql) so within minutes I had it hooked up to the same database that contains my time tracker tables.

With a few tweaks to the user interface in order to incorporate the time tracking pages and a little bit of work to blend the security models of the two applications I was ready to go.  The whole process took less than 24 hours of development and deployment!  At this point I'm experimenting with building BlogEngine widgets (like the delicious bookmarks sidebar that you see over to the right).  My next post will feature the code for this widget.



Site Update!

Finally!  The site update is in progress...it's about time considering that the purevirtual.biz site was last updated some time in 2002.

Lots of great new functionality coming soon including an integrated client section for clients to view their account details/invoices, etc.    Also a time tracker is integrated as well as the blog functionality.

I'll be publishing more functionality and content over the next few days.

~nate


pureVirtual Services, LLC © 2008

Latest Alasdair Pics


What I've Been Reading


delicious feed  [http://delicious.com/purevirtual]