Archive for the 'Web Dev' Category

ProRubyConf08 Wrap Up

This past week I attended the Voices That Matter Professional Ruby Conference in Boston with three of my co-workers from Sports Technologies. I learned a lot from all of the speakers and it was great to meet other Rubyists and hear about the types of things they are working on.

ActsAsFlinn and Myself talking to the guys from ThoughtBot
ActsAsFlinn and Myself talking to the guys from ThoughtBot

Some of the best things I took away from the conference were to focus on testing, and push to improve the process of the product cycle where I work. I also got a lot out of watching the guys from ThoughtBot talk about refactoring code. They had a lot of good tips.

Nick Quaranto (pictured on the left in the photo above) did a great job live blogging the conference and took notes with all the sessions.

Matt Bauer did a talk about Berkeley DB and used a cycling related application he is working on called Pedal Brain for some of the examples. I talked to him briefly about it, and I am excited to see what comes of it. Hopefully I can help beta test!

Dan Patrick Weekly Challenge

This week I launched the Dan Patrick Weekly Challenge pick’em game on FanNation.com. It is a similar game to others I have developed recently. One new thing is groups that are specific to the game (instead of FanNation groups) and the ability for users to join multiple groups.

Dan Patrick Weekly Challenge

The interface is laid out using absolute positioning, and uses javascript to set hidden form fields when a user clicks on the option they pick to win, an then updates the css class to set the background image on the element to indicate which option is selected. With this application I built some admin pages where the producer of the Dan Patrick show can enter the matchups and set the winners. The designer at SI cuts logos or images to go with each matchup, so there are input fields for the image URLs as well.

This is a pretty simple game that could be reskinned to let users pick any type of matchups. Our Sports Technologies web site has been updated recently.

Bracket Challenge Project

My latest project that I devoped for FanNation / SI.com is the Seth Davis Bracket Challenge for the NCAA Tournament. To date this project has probably been my most complex Ruby on Rails application. I was also really happy with how the interface for picking your bracket turned out. It is all html, css, and javascript based (as opposed to ESPN’s Flash interface for picking teams).

I used a sliding window effect where a div with smaller dimensions set to overflow hidden wrap a div with a greater height and width. After the user saves a region via Ajax, I used the scriptaculous Effect.Move function to animate the screen moving to the next region.

Scrolling SDC Screenshot

Some of the challenges I was faced in this application included clearing out downstream picks if you changed a team in a earlier round that you had advancing farther down the bracket, and displaying pick percentages for each team at each round as you are making picks.

To solve the first issue I set a javacript array that included all the match ids and match position (top or bottom) that were downstream of every match, and when a user clicks a team to select the pick I checked if the opponent in that match was already selected in a position down the bracket and cleared it out.

To dynamically display the pick percentages as you move a team, I printed out a javascript array (actually a JSON object) that listed every team id, and an hash of each percentage ar each round when the page is loaded. Then when the user clickes on a team to advance it, I cloned the innerHTML of the div they were selecting and replaced the innerHTML of the percentage div with the percentage of that team for the next round.

After all the work I put into this, it’s too bad that the interface is only viewable for four days to the users until the game locks before the tournament begins. Hopefully we will make use of the code for next year’s bracket or some other fantasy games we build in the future.

I’m on Rails

For a long time now I have wanted to rebuild BikeRide.com from the ground up. It is a site I started a long time ago, and I haven’t really given it the attention it deserves. Since I wanted to make a fresh start, I also thought it would be a great time to learn Ruby on Rails. I looked into some other options like the Symfony framework for PHP, or possibly building a site with Drupal, but in the end I chose Rails.

My background has been in using classic ASP, and at ESPN / Disney we use a proprietary scripting language called Tea. So, whether I chose a PHP framework, or Ruby on Rails there would be a learning curve getting used to the syntax.

I followed Dan Benjamin’s steps on setting up a Ruby on Rails development environment on OS X. It was a big help in getting things working. I had a little trouble connecting to mySQL, but that was because I tried to create a database name with an illegal chatacter in the name. Once I figure that out I was good to go.

The first thing I did was install the plugin for Acts as Authenticated which gave me a big head start with setting up a user registration and authentication system.

I am just getting started and I have a lot to learn, but so far I have joined the Ruby on Rails Google Group, and bought the Agile Web Development with Rails book

Some things I have planned for BikeRide.com include a much better events calendar where users will be able up add and manage their own events. Users will be able to check events that they plan to participate in. Sort of similar to Upcoming.org, but just for cycling events.

I plan to move all bike related links to a database backed system where users can suggest new links, and possibly rate, or mark links as a favorite. Links will be organized with tags instead of the single category designation that is there now.

Those are just two of the things I have planned. I have more ideas as well, but I don’t want to give too much away, and I’d first like to get the current main features of events and links, then add to it from there.

Digg Releases API

Digg.com has just realeased an API (Application Programming Interface) for web sites or application developers who would like to use their data. I can already think of some good uses for their data. Things like displaying any stories from your site that have been dugg can now be done through the API.

I’m on Twitter

I signed up for a Twitter account. If you don’t know what Twitter is, it is the latest, greatest, social/Web 2.0 web application. The idea is to post what you are doing. You can add friends so you can see what your friends are doing. My username is bikeride. You can send or get updates from a mobile device or IM. I’d like to use the API to automatically update Twitter when I publish a blog post, create a new flickr photoset, bookmark something with del.icio.us, or share an item in google reader, or add a new training log entry. Maybe I’ll get to it.

Google Reader vs. Bloglines

I have been a big fan of Bloglines. Over the past year I find myself consuming most of my web content with feeds through Bloglines. I find myself visiting sites less if they don’t have an RSS feed. CyclingNews.com is one of those sites. Although they have probably the most in depth cycling coverage, they don’t have an RSS feed, so it make it inconvenient to get their content when I can quickly go through feeds with a newe aggregator like Blogllines. VeloNews.com has an RSS feed, but it isn’t formatted correctly and they don’t have rel tags on their site to make the RSS feeds automatically discoverable by the browser.

Google just released a new version of Google Reader. After looking at a video describing some of the features I was sold to switch from Bloglines. For me the ability to share is becoming very important with social web applications becoming so popular. The feature that got me to switch was the ablility to mark articles as shared, and let other people see or subscribe to a feed of items that I find interesting.

It was easy to export my feed subscribtions from Bloglines to a standard opml file and import those into Google Reader. If you use Gmail, the Google Reader UI will be familiar.

Geocode your photos with Flickr

Flickr just added the ability to geocode your photos. I’m sure I will be wasting a lot of time playing with this. I already stayed up late last night mapping my photos with the nifty Flickr photo organizer. The Flickr API has been updated so that now you can access the geocoding data. I can already think of some cool ways to use this. For example, it would be cool to show photos tagged with cycling near the loctaion of the events listed in bikeride.com. To learn more how to geocode your photos, go to the Flickr blog post.

Flickr API Example using ASP and JScript

I recently set up the photo gallery page of BikeRide.com using the Flickr API. I wanted to pull in all my sets that include cycling photos. I couldn’t see an API method for making a call to get all my sets with photos containing the tag “cycling.� That would have been the best way to make a maintenance free page, but I have to start with making an array containing the setIds of my cycling related photos.

The code loops through the ids, make an API call to get the set information including the title, description, number of photos in the set, and the id of the primary photo to display for the set.

The next step is to make an API call to get individual photo information to get the URL for the image on Flickr. The code example is below.


output='';
galleryHTML='';

// Lock application and set variable for caching purposes
Application.Lock();	//Lock the application object

if (new Date().getTime() > (Application("galleryTime") + 36000)) { // caching - execute if more than 10 minutes old;

	// My Flickr Set IDs - Just add a new id the next time a set is added to flickr
	setIds = new Array(
		'72157594215842408', //2006 FSA GRAND PRIX
		'72157594214549645', //2006 RAMROD
		'72157594201502432', //2006 NYC Triathlon
		'72157594168641657', //2006 Pat Griskus Triathlon
		'72157594146912138', //2006 EBCC Bash Bish 200K
		'72057594121299286', //2006 Shelbourne Falls 200K
		'72057594079933400', //2006 Plainville Crit
		'1352705', //2005 Chainbiter Cross
		'1145739', //2005 Litchfield Fall Ride with Gordon
		'712816', //2005 Tour of the Litchfield Hills
		'415217', //2005 Quabin 200K
		'408170', //2005 Tour of CT
		'408191', //2005 Bershire 300K
		'408452', //2005 Berkshire 100K
		'762107', //2004 Chainbiter Cyclocross
		'411413', //2004 Southington Cyclocross
		'411569', //2004 Stockbridge Century
		'408851', //2004 Philly USPRO
		'767925', //2004 Tour of CT
		'762481' //2003 World Championships
	)

	for (i=0;i<setIds.length;i++) {
		url = 'http://www.flickr.com/services/rest/?method=flickr.photosets.getInfo&photoset_id='+setIds[i]+'&api_key=[myFlickrKey]'

		// Create an ASP XML parser object
		var xml = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
		xml.open("GET", url, false);
		try {
			xml.send();
			if (xml.status == 200) {

				xmlDoc = xml.responseXML
				xmlDoc.setProperty("SelectionLanguage", "XPath");
				photoset = xmlDoc.selectNodes("//photoset")
				if (photoset && photoset.length > 0) {
					setId =  photoset[0].getAttribute("id");
					photoId = photoset[0].getAttribute("primary");
					server = photoset[0].getAttribute("server");
					count = photoset[0].getAttribute("photos");
					title = photoset[0].getElementsByTagName("title")[0].firstChild.nodeValue;
					desc = photoset[0].getElementsByTagName("description")[0].firstChild.nodeValue;
					imgurl = photoId;

					//Now make anothe API call to get the right photo size to dislplay
					var xmlSizes = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
					sizesURL = 'http://www.flickr.com/services/rest/?method=flickr.photos.getSizes&photo_id='+photoId+'&api_key=[myFlickrKey]';
					xmlSizes.open("GET", sizesURL, false);
					try {
						xmlSizes.send();
						if (xmlSizes.status == 200) {
							xmlSizesDoc = xmlSizes.responseXML;
							xmlSizesDoc.setProperty("SelectionLanguage", "XPath");
							sources = xmlSizesDoc.selectNodes("//size[@label='Square']");
							if (sources && sources.length > 0) {
								imgurl = sources[0].getAttribute("source");
							}
						}
					} catch(e) {

					}
					xmlSizes = null;
					// Build the html to output - ok - I know I need to take my css
					output += '<div class="photobox"'>'
					output += ''<div class="galleryphoto"><a href="http://www.flickr.com/photos/bikeride/sets/' + setId + '/">'<img src="'+imgurl+'" width="75" height="75" border="0" alt="'+title+'" />'</a></div>'
					output += ''<div style="height: 85px;">'
					output += ''<strong>'+title+'</strong> ('+count+' photos)<br />\n'
					output += desc + ' ';
					output += ''<a href="http://www.flickr.com/photos/bikeride/sets/'+setId+'/">View Photos ...</a>\n'
					output += ''</div>'</div>\n'

				}

			}
		} catch(e) {

		}
		xml = null;
	}

	if(output != '') {
		Application("galleryHTML") = output;
	}

	Application("galleryTime") = new Date().getTime();

}		

galleryHTML = Application("galleryHTML");

Application.UnLock();	//Unlock the application object

Response.Write(galleryHTML);

I will still need to add an Id to the code the next time I add a set of cycling photos, but that is it. I would like to play more with the API and make an Ajax style photo gallery on top of the Flickr API.

Automated Cycling Headlines on BikeRide.com

My latest upgrade to BikeRide.com was adding headlines pulled in from RSS Feeds. I set this up using XML over HTTP. In ASP this uses MSXML2.ServerXMLHTTP.4.0. New RSS feeds are fetched once an hour from VeloNews, PezCyclingNews, CyclingUSA, Active.com, EuroSport, and Cycle-Smart. When the new RSS feeds are parsed, any new URLs are added to a database table, then that table is queried to pull the top 25 latest headlines for the BikeRide.com index page. This was actually pretty easy to set up, and made me wish I had done this a long time ago. Now I have up to date news headlines on the site with no manual updating.




About Brent

I have been a Web Developer since the early '90s working on some of the highest traffic sites on the internet such as MSN.com and ESPN.com. Since 2007 I have been using Ruby on Rails while working for Sports Technologies, a small internet company in Connecticut, developing features for FanNation.com and Fantasy Sports applications for Sports Illustrated.

I am interested in all things related to Social Media, User Experience, and creating great Web Applications.

I am a Cycling enthusiast who raced competitively for many years, and still try to get out and ride as much as I can. I created the site BikeRide.com and have developed some other cycling related sites in the past.

I am a husband, and the father of two girls. I grew up in western Washington, but now live in Connecticut.