.Net Code Monkey RSS 2.0
 Tuesday, April 21, 2009

Hill Work

As I didn't get a chance to get out on the Guess RB1 for my normal 8 mile ride before work this morning, I thought I ought to get out on it for a quick ride tonight. My 8 mile morning ride is pretty flat, so I thought I'd incorporate Lanehouse hill and New Road on Portland for a bit of hill work. Lanehouse wasn't too bad, I think I didn't go lower than second but New Road is always a bit of a killer, and wasn't looking forward to that.

The Flat Bar Bike Bloke

On my way accross the beach road as I passed the location of the old oil tanks I passed a chap on a flat bar bike. I didn't rally think much of it, as he seemed to be cruising. I carried on my way round Vicky Square and up the zig zag into Fortunes Well. As I reached the shops I could hear the sound of a deraileur change behind me. I could hear the cyclist behind was keeping right up behind me, so I kept my pace slight as high as I thought I could maintain.

Burned Off

Sadly it appeared it was too hight at first as I virtually died at the ninety right at the bottom of New Road, and had to rrsort to first and second. At this point the flat bar bike bloke stood up on the pedals and rode round me, pumping all the way up the hill, dropping me like I was stood still. What is more he was half way down the sprocket to boot! I didn't even attempt to keep up, my legs were shot. When I rounded the hairpin he was no where to be seen, neither was he when I reached the roundabout at Dowsett's old garage. one thing for sure his legs were a lot bigger than mine, but not suprising if he climbs like that every day!

Tuesday, April 21, 2009 6:21:39 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Bikes | Cycling | Guess RB1
 Monday, April 20, 2009

Back on the road...

Although I haven’t been without a bike of some time since about the age of five, I haven’t had a road bike for well over 15 years. Although I currently have a full suspension XC mountain bike, I have been mulling over getting a road bike for a couple of years. Recently I made the decision to get one.

I started researching what sort of machine I could get second hand off eBay, and started watching bikes listed locally, or with a postage option. I could see that for anything from £200-£300, my budget, I could get an aluminium frame maybe with carbon forks and some other carbon components.

I missed out on a few machines going on eBay for various reasons, but while I was bidding on one, I thought I ought to pick the brains of the local bike shop proprietors, and see if they ever get trade-ins. The chap at one of the local shops (Westham cycles) was very informative, but did recommend to leave second hand bikes alone as they have a huge waiting list for second hand road bikes. He suggested that I save up for the new 2009 GT GTR series 4 that would be due in at the start of May. Save up? I wanted one there and then, he-he!

I went to the next shop, Cycle Life, expecting to hear pretty much the same thing about second hand bikes, but he suggested I take a look at a matte black beast of a bike in the front of the shop. I’d never heard of the make “Guess” before. I wondered if it stood for “Guess who really makes it?” This is something I have yet to find! He advised me that he was selling it for a friend who wanted £450 for it, this was quite a bit over my budget.

As I tried it for size, he told me a fair bit about it, including that it had up-rated Campagnolo Scirocco wheels. I have since found them listed new for about £250; half the price the bike would be if new. I asked if it would be a good base to start from, if I wanted to upgrade to better components later on. He suggested it would be, as it was a good frame and forks setup.

I went home to mull it over and discuss it with my girlfriend. I would have to put it on the credit card, but I had done a little website work, so was due some money in my account soon. She said do a bit of research first, but if after that I still want it, why not get it. After all, life is too short. I couldn’t find much about it on the web. Only that SuperCycles seem to be the only place that stocks it. I had read a couple of accounts from people who owned one, and all but one was positive. The negative one only complained about the standard wheels, and as this one had up-rated Campagnolos wheels already on it, I didn't need to worry about that.

I decided to go back to the shop and make an offer. The first was rejected but we came to agreement on the second offer. After the bike was given a good once over by the shop owner, I was now once more the owner of a road bike!

I'll detail and review the bike in a seperate article coming soon.

Guess RB1

Cycle Shops

Cycle Life

28 Abbotsbury Rd,

Weymouth,

DT4 0AE

01305 781831

[Link to follow]

 

Westham Cycles

128 Abbotsbury Rd,
Weymouth,
DT4 0JS
01305 776977
http://www.westhamcycles.com/

 

Super Cycles

http://www.supercycles.co.uk/

Monday, April 20, 2009 5:38:12 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Bikes | Cycling | Guess RB1
 Sunday, February 22, 2009

Background

I was recently asked by a friend to help him implement the website code part of Brandon Fuller's 'Now Playing' plugin for iTunes. The code Brandon provides is PHP, and I felt that would be limiting if my friends website ever had to move to a non PHP enabled web server. With this in mind I decided to convert and modify his PHP script to be JavaScript only. This article covers the code created to do so.

The Solution

Below is the javascript file to include on your website.

Javascript Code

You will need to set up a few values in the pseudo-constants section of the code first.

  • REMOTE_XML_URL - is the remote url for the 'now_playing.xml' published by Barndon's ITunes plugin.
  • DISPLAY_ARTIST, DISPLAY_TITLE and DISPLAY_ALBUM  - are flags for if to display these element.

The remainder of the constants all declare element IDs or css classes for the elements the javascript creates.

Lastly you will also need to set the _artworkUrl variable to point to the the default artwork url for when album artwork is not available.

 

/*
File:       NowPlaying.js
Author:     Duane Wingett
Date:       21st February 2009
Purpose:    For use with Brandon Fuller's "Now Playing" iTunes addon, see:
            http://brandon.fuller.name/archives/hacks/nowplaying/
            for more details.
Browser Compatability:
            checked (Tested on)
            IE 6.0.2
            Opera 9.52
            Firefox 3.0.5
            Netscape 9.0b3
            Safari (Windows) 3.2.1
            Chrome 1.0
Usage Policy:
            You are free to use / distribute this code without charge, 
            providing this acknowledgement remains intact ane no
            profit is gained from use.            
*/

// Constant Declarations
var REMOTE_XML_URL = 'http://www.mySite.com/NowPlaying/now_playing.xml'; // Remote location of NowPlaying xml file
var DISPLAY_ARTIST = true;
var DISPLAY_TITLE = true;
var DISPLAY_ALBUM = true;
var OUTER_CONTAINER_IDENTITY = 'NowListeningTo';
var IMAGE_CONTAINER_IDENTITY = 'ListeningImageContainer';
var TEXT_CONTAINER_IDENTITY = 'ListeningTextContainer';
var OUTER_CONTAINER_CSS_CLASS = '';
var IMAGE_CONTAINER_CSS_CLASS = 'FloatLeft';
var TEXT_CONTAINER_CSS_CLASS = 'FloatLeft StudioInfoTextContainer RightBorder';
var ARTIST_TEXT_CSS_CLASS = 'StudioInfoText';
var TITLE_TEXT_CSS_CLASS = 'StudioInfoText';
var ALBUM_TEXT_CSS_CLASS = 'StudioInfoText';
var IMAGE_CSS_CLASS = 'NowPlaying';
var CONTENT_DIV_ID = 'x'; // ID of div to insert NowPlaying html into

// Declare variables - some with default values
var _artist = 'Unknown';
var _title = 'Unknown';
var _album = 'Unknown';
var _artworkUrl = 'http://www.mySite.com/Images/MusicNoImage.gif'; // Remote location of no image file
var _isIe = isIe();
var _xmlDoc;

// Purpose
//  Detects if browser is IE
//
// Returns:
//  true if it is.
//
function isIe()
{
    return navigator.appName.indexOf("Microsoft")!=-1;
}

// Purpose:
//  Loads the remote XML file into global variable.
//
function loadXml()
{
    try
    {
        if (window.ActiveXObject)
       {
            _xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            _xmlDoc.async=false;
            _xmlDoc.onreadystatechange = populateArtistInfoFromXml;
            _xmlDoc.load(REMOTE_XML_URL);
        } else {
            // Opera, Mozilla, Safari & Chrome
            var xmlhttp = new window.XMLHttpRequest();
            xmlhttp.open("GET",REMOTE_XML_URL,false);
            xmlhttp.send(null);
            _xmlDoc = xmlhttp.responseXML.documentElement;
            _xmlDoc.onload=populateArtistInfoFromXml();
            xmlhttp = null;
        }
    }
    catch(e)
    {
        alert(e.message);
    }
}

// Purpose:
//  Populates global fields from global xml doc.
//
function populateArtistInfoFromXml()
{
    try
    {
        if(_xmlDoc != null)
            { 
            if((_xmlDoc.readyState == 4) || (!_isIe))
            {
                //alert('loading values from doc..');       
                if(getNodeValue(_xmlDoc, "title") != null)
                {
                    _title = getNodeValue(_xmlDoc, "title");
                }
                if(getNodeValue(_xmlDoc, "artist") != null)
                {
                    _artist = getNodeValue(_xmlDoc, "artist");
                }
                if(getNodeValue(_xmlDoc, "album") != null)
                {
                    _album = getNodeValue(_xmlDoc, "album");
                }
                if(getNodeValue(_xmlDoc, "image") != null)
                {
                    _artworkUrl = getNodeValue(_xmlDoc, "image");
                }
            }
        }
    }
    catch(e)
    {
        alert(e.message)
    }
}
// Purpose: // Gets and the value from passed in XML document // for the passsed in node name. // // Returns: // value if found or null; // function getNodeValue(xmlDoc, tagName) { var value = null; try { if(_isIe) { value = xmlDoc.getElementsByTagName(tagName)[0].text; // IE } else { value = xmlDoc.getElementsByTagName(tagName)[0].textContent; // Opera, Mozilla, Chrome, Safari } return value; } catch(e) { alert(e.message) } } // Purpose: // Renders the NowPlaying html. // // Inputs: // artist - The artist's name // title - The track name or song title // album - The album name // function renderNowPlaying() { loadXml(); var sb = new StringBuilderEx(); sb.appendFormat("<div id='{0}'>\r\n", OUTER_CONTAINER_IDENTITY); sb.appendFormat(" <div id='{0}' class='{1}' >\r\n", IMAGE_CONTAINER_IDENTITY, IMAGE_CONTAINER_CSS_CLASS); sb.appendFormat(" <img src='{0}' class='{1}' title='{2}' alt='{2}' />\r\n", _artworkUrl, IMAGE_CSS_CLASS, _title); sb.appendFormat(" </div>\r\n"); sb.appendFormat(" <div id='{0}' class='{1}' >\r\n", TEXT_CONTAINER_IDENTITY, TEXT_CONTAINER_CSS_CLASS); if(DISPLAY_ARTIST) { sb.appendFormat(" <p class='{0}' >{1}</p>\r\n", ARTIST_TEXT_CSS_CLASS, _artist); } if(DISPLAY_TITLE) { sb.appendFormat(" <p class='{0}' >{1}</p>\r\n", TITLE_TEXT_CSS_CLASS, _title); } if(DISPLAY_ALBUM) { sb.appendFormat(" <p class='{0}' >{1}</p>\r\n", ALBUM_TEXT_CSS_CLASS, _album); } sb.appendFormat(" </div>\r\n"); sb.appendFormat("</div>\r\n"); var containerDiv = document.getElementById(CONTENT_DIV_ID); containerDiv.innerHTML=sb.toString(); }

You may want to provide a little more error handling and checking for returned null values here and there to.

Html Code

Below is the HTML for the page to display teh now playing infomation. You need to place an empty div in the page and assign it the same ID that you set in the JavaScript constant "CONTENT_DIV_ID". You need to link to the two JavaScript files "StringBuilderEx.js" and "NowPlaying.js". Include a stylesheet to add your own styling and behaviour to the JavaScript created divs Finally call the "renderNowPlaying()" method after the empty div.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Now Playing Test Page</title>
    <link href="StyleSheets/BehaviorStyles.css" rel="stylesheet" type="text/css" />
    <link href="StyleSheets/AppearanceStyles.css" rel="stylesheet" type="text/css" />
    </script src="Javascript/StringBuilderEx.js" type="text/javascript" charset="utf-8">
    </script src="Javascript/NowPlaying.js" type="text/javascript" charset="utf-8">
</head>
<body>
    <div id="StudioInfoContainer" >
        <div id="x"><!-- Now Playing will appear here --></div>
        <script language="javascript" type="text/javascript">
            renderNowPlaying();
        </script>
    </div>
</body>
</html>

Summary

So there you have it a basic web site side implementation of Brandon's Now Playing feature. Feel free to use, alter or extend any of the code in this article.

Compatability

My the 'NowPlaying.js' JavaScript code has been tested and appears to work on the following browsers:

  • IE 6.0.2
  • Opera 9.52
  • Firefox 3.0.5
  • Netscape 9.0b3
  • Safari (Windows) 3.2.1
  • Chrome 1.0

Note

Full implementation of Brandon Fulller's 'Now Playing' iTunes plugin can be found on his website, the link is below.
The JavaScript extended StringBuilder class used in this code is courtesy of Ferreri Gabriele and can be found at the CodePrroject link, below.

Links

Brandon Fuller's Plugin
Ferreri Gabriele's JavaScript StringBuilder

Sunday, February 22, 2009 10:28:09 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Html | JavaScript | iTunes
Archive
<April 2009>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Blogroll
 Clemens Vasters
 Harry Pierson
Passion * Technology * Ruthless Competence
 Joshua Flanagan
A .NET Software Developer
 Michael Schwarz's Blog
Developing applications on the Microsoft platform since Windows 3.1!
 Omar Shahine
Yet another Microsoft blogger
 Scot GU
Scott Guthrie lives in Seattle and builds a few products for Microsoft
 Scott Hanselman
Programming Life and the Zen of Computers
 Tom Mertens
Tom's corner
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Duane Wingett
Sign In
Statistics
Total Posts: 26
This Year: 0
This Month: 0
This Week: 0
Comments: 28
Themes
Pick a theme:
All Content © 2010, Duane Wingett
DasBlog theme 'Business' created by Christoph De Baene (delarou)