Showing posts with label Technology. Show all posts
Showing posts with label Technology. Show all posts

Saturday, November 13, 2010

iPhone Taking Forever to Back Up?

So I'm finally taking the plunge and upgrading my iPhone to OS 4.1. As I've mentioned here before, I very rarely plug my iPhone into iTunes. I just charge it from the wall or car charger, rarely sync it. Mostly because it takes so damn long to back up.

But this time, since I'm doing an OS upgrade, I figured I'd better let the backup run. Several hours after kicking it off, the backup progress meter has hardly moved. I'm leaving on a trip tomorrow, so I don't have time for Apple crapware shenanigans, so I start doing some reading.

It turns out that there's an obscure setting that gets defaulted to 'true' that has your device send it's usage data and crash reports to Apple every time it sync's. You have to queue up to upload that data alongside everyone else on the planet that's currently synching. When I found my crashdump folder it had over 60 dumps in it. Goddammit Apple!  Get your garbage off my computer!

This forum posting has instructions for how to reset that setting. It's not easy, you won't find it by poking around.
The Idiots Guide to Making your Iphone Backup fast

In case that forum thread ever vanishes, here it is in a nutshell.

1. Start a sync, but cancel it, so you have your device listed in iTunes, but not currently locked up.
2. Right-click and select "Reset Warnings" from the context menu.
3. Next time you sync, you should see a dialog box like the following.
4. Click "No Thanks".  That'll get you out of the queue for crashdump reporting on every sync.



I'll drop an update later as to how the upgrade goes and the backup situation.  Don't get me started on the fun of moving an iTunes Library from computer to NAS drive . . . which is what I spent the first half of the weekend doing.  

Sunday, May 30, 2010

Template Upgrade

Since Google announced the Blogger Template Designer I've been meaning to rework my site. There was a fair amount of hackish stuff in my template HTML, including a bunch of monkeying around to make my main post column wider yet still use the rounded corners on the old table based layout.

The new template I picked out is much simpler and cleaner looking. Amazingly, pretty much everything came over with no effort on my part. I did end up spending some time reworking the color schemes of my Tumblr and Flickr widgets. And I cleaned up some minor CSS and Icon annoyances.

I also took a look out at Flickr to see if they've upgraded their Badge Widget generator anytime recently. They have not, so my Flickr badge generator is still valuable. Looking at it again after all these years, it basically just hides the default Flickr table, draws my 2x5 table, then uses some script to pull the InnerHTML of the the Flickr cells containing 10 random images, and poke them into my cells. Like so:


<td class="robCell"><div id="rob1"></div></td>

. . .

document.getElementById("rob1").innerHTML
= document.getElementById("flickr_badge_image1").innerHTML;


I'm sure there are much more elegant ways to do this (one of these days I'll get off my ass and finish learning JQuery and/or Prototype), but for now, this is still working. No need to fiddle with it now that I've updated the colors and fixed the margin/padding/border issues that were bugging me.

The Tumblr Badge was even easier, that was just a few color tweaks, though again I messed with the margin/padding/border settings to bring things in a bit tighter.


/* Rob Styles*/
.tumblr_photo
{
width: 125px;
height: auto;
float: right;
margin: 3px;
padding: 0px;
border: 3px #444444 solid;
}

.tumblr_posts
{
float: left;
margin: 0px;
padding: 0px;
margin-left: -10px;
}

.tumblr_post
{
font-size: x-small;
list-style-type: none;
width: 215px;
margin: 0px;
padding: 0px;
margin-top: 5px;
margin-bottom: 5px;
max-height:210px;
overflow: hidden;
border: thin black outset;
background-color: #222222;
old-background-color:#78a;
}
.tumblr_caption
{
padding: 2px;
margin: 2px;
}


Thursday, April 08, 2010

iPhone Not Recognized as a Camera

It's not very often that I physically plug my iPhone into my computer. Mostly because when I plug it into my old laptop, it's a hassle to get it recognized, then it takes hours and hours to back up and synch. I've mostly got what I want on it, so I only plug it in if I really have to grab a firmware update, or really want some bit of new music or a large app update that won't come down over 3g.

But every now and then, I do use it as a camera, and there's something I really want from it. I'll dig out the white Apple proprietary USB cable and plug in. Usually I get the 'searching for driver' bit, then a fail. At work, I'd written it off as a big-brother firewall problem at first (blocked driver download). Then I discovered that my cube neighbor's iPhone worked on my machine, and my phone also failed on his machine . . . so much for a driver issue. I figured maybe a phone issue. Anyway, I can't be bothered with troubleshooting USB devices to get one photo, so I'd email it to myself. At home I'd just roll my eyes and fire up iTunes . . . after a few restarts of the Apple Mobile Device Service and a couple unplugs and replugs, maybe a reboot of the phone, it would be recognized as a device, and I could get the pictures out with Picasa.

But now I've got a new laptop. I really don't want to put iTunes on it until I'm ready to retire my old laptop, because I don't want to mess around with having to deauthorize all my former computers in order to authorize my new one (don't get me started on that, that's a whole other topic).

So when I plug the phone into my new laptop and it comes up as 'random usb thing which by the way failed to start' - it's on!

Google's taken all the fun out of low level troubleshooting, but there's no sense spending hours and hours on something that's common knowledge, so I did some searches. I turned up the usual crap from Apple and Apple cultist forums about updating to the latest firmware, rebooting your iPhone, rebooting your PC, updating to latest iTunes, reinstalling iTunes, blah blah blah.

Then I spotted something on a Microsoft site: 'Windows 7 will not recognize my iPhone as a Camera' [1] . That's promising, my exact symptoms, and a Microsoft forum, so it should (one would think) be free of Apple bullshit. So taking a look at it, the first response (which by the way is marked as 'the answer') links to some Apple KB article talking about USB drivers being 'out of date'. What an absolute load of crap, what kind of flakey garbage hanging on the end of the cable is going to have a problem with fresh out of the box Win7 USB drivers, or any drivers for that matter. You're doing something wrong if your hardware is worried about USB driver minor versions on various operating systems.

Just out of curiosity regarding peoples luck with this 'solution' I scrolled down the page . . . where I spotted this:

"There is something wrong with the firmware in the iphone. If you have any photos that are in your photo album within the phone that are there from any source except the phone itself such as an emailed photo or downloaded photo, PC's and Macs will not recognize your phone. You must delete the "foreign pictures" then the Mac or PC will recognize the phone."

Now that sounded more like the Apple crapware I know. I've always had 'foreign pictures' in my Camera Roll. And I know that was not always a problem, as I've used that space to move images from photo collection to photo collection at times. But annoying as it was, it had the sound of the sort of bug Apple would roll out, so I thought I'd give it a try. I did a quick run through and deleted every image that wasn't taken by the iPhone. Lo and behold, plug it in, it pops up as a camera . . . hmm. Figuring I'd repro it, do my bit, and properly report a firmware bug to Apple Dev. . . I pulled down a couple large images from my Flickr, and some PNG files off XKCD, but was unable to reproduce the problem again . . . go figure. *sigh*

How do people that make such terrible software, get their hands on such awesome hardware to defile with their garbage?

Anyway, if your iPhone's not recognized as a camera, try cleaning out your Camera Roll.

I'm gonna go kick a mac.

Saturday, August 29, 2009

Tumblr Badge for Blogs and CSS Troubleshooting

My post on how to use CSS to restyle Tumblr's default blog widget has been quite popular. One commenter pointed out that it wasn't displaying properly in IE6 or IE7 (surprise). After a bit of investigation, it turned out to be the Usual Suspect: browser differences in default Box Model behavior.

Specifically, it appears that IE versions lower than 8 use a large amount of default margin to move elements to their default starting position in a container.  Firefox, Chrome, and Safari, on the other hand, seem to use about the same amount of space, but in Padding. You can see the difference in the two screen captures below.   The Red border is the Tumblr_Posts div.


Note that in Firefox above, the whitespace is on the inside of the Div, it's "Padding" of about 50 pixels. In IE below, it's also about 50 pixels, same resulting position, but caused by outside the Div "Margin" space.


My goal with the stylesheet was to keep a minimum of whitespace between the outer container (Green border), and the little photo boxes (inside the red box). I did that with the first CSS property that came to mind: Margin-Left. I raised that number until it looked how I wanted it in Chrome, doublechecked it in IE8, Firefox, and iPhone Safari, then published it. Unfortunately, since IE6 started with Margin-Left at about 50px, the impact of setting Margin-Left to -30px was a 80px move in IE (compared to 35px in most other browsers). The result was the posts were chopped off about halfway across by the border of the sidebar.

The solution, as with most things in computing, is to reboot. ;-) Specifically, set all the box model numbers to the one number that puts all browsers on equal footing: zero.

Zeroing out both margin and padding did exactly what I wanted in the first place: let the Tumblr Post boxes fill the containing div. Any number would work actually, as long as you set them all explicitly, rather then letting the browsers use their assorted defaults.

.tumblr_posts
  {
    margin: 0px;
    padding: 0px; 
  }


Anyway, hope that helps. If you went and read up on the CSS Box Model, or have wrestled with this stuff before, you'll probably find this amusing:

CSS is Awesome! Mug on Zazzle


Here's the current, corrected CSS:

.tumblr_photo
  {
    width: 110px;
    height: auto;
    float: right;
    margin: 7px;
    border: 2px black solid;
  }
  .tumblr_posts
  {
    margin: 0px;
    padding: 0px; 
  }
  .tumblr_post
  {
    font-size: x-small;
    list-style-type: none;
    width: 210px;
    padding: 7px;
    margin: 5px;
    max-height:200px;
    overflow: hidden;
    border: thin black outset;
    background-color:#78a;
  }

Sunday, March 15, 2009

Flickr, Tumblr, and a Tumblr Badge Widget for Blogs

I've really been loving Tumblr lately. It's been making my photo publishing workflow a lot simpler.

Here's the typical process now:
  1. Take a bunch of photos.
  2. When I get home, pull out the memory card and import everything into Picasa.
  3. When I get time, flip through the photos in Picasa. Delete crap ones, Star the good ones, tag others for repair or editing later.
  4. Select the Starred photos in Picasa and hit the Picasa2Flickr button. This little guy is a huge win. It basically just chucks all the photo file names onto a command line for the Flickr Uploader. You can set titles, descriptions, and tags as a batch.

Now here's where Tumblr starts to come in handy. I've always been tagging some of my favorite photos with "BlogBadge", which causes them to be eligible for appearance in the random 10 photos that go in the Flickr badge in the right sidebar. That thing uses the Flickr API, a bit of script and a bit of CSS, but I've forgotten how I originally did it, so that's a whole other post for later.

Anyway, I configured Tumblr to subscribe to the RSS feed for "BlogBadge" tagged photos as well.
So Tumblr will pull in the photo, it's title, and description. I've then set up Facebook to pull the Tumblr feed. So that saves me the trouble of cross-posting photos to Facebook.

Now to save the trouble of posting tiny little "here's what I did last weekend and a couple of photos" posts to Blogger, I created a little badge widget for my blog sidebar.

Tumblr provides a basic script to pull badge HTML, but the images are full size.

<script type="text/javascript" src="http://rengber.tumblr.com/js"></script>


I've whipped up a bit of CSS to cut down the image size, tweak the colors, and contain the Tumblr post text into a sidebar box. Just stick the following in your stylesheet, or in a style tag near the widget script.


.tumblr_photo
{
width: 110px;
height: auto;
float: right;
margin: 7px;
border: 2px black solid;
}

.tumblr_posts
{
margin-left: -50px;
}

.tumblr_post
{
font-size: x-small;
list-style-type: none;
width: 210px;
padding: 7px;
margin: 5px;
max-height:200px;
overflow: hidden;
border: thin black outset;
background-color:#78a;
}


So from a simple batch Flickr upload, I've now covered both my Blog and Facebook, and the photos are available via iPhone. Which brings me to the main reason I love Tumblr: their excellent iPhone app.

From the dashboard of the Tumblr app, I can post any photo from the iPhone, and using CoolIris or Flickr mobile, I can pull any Flickr photo into the iPhone. Which means that I can do simple photo updates easily on the bus ride to or from work every day. Much more pleasant than messing around in Blogger (which is quite painful from the iPhone).

Saturday, February 07, 2009

Digital Inventory

iPhone Screen Capture
Picking up an iPhone has made me take stock of all the applications and sites I use to ourganize myself and keep in touch. At this point, I should be able to do most of the miscellaneous organizing and reading I do on a computer from my iPhone.

Calendar: Google Calendar - synched with iPhone calendar app via Nuevasync.
Mail: Gmail - iPhone mail connects.
Tasks: Remember the Milk + free iPhone client.
Work Notes: Combination of TiddlyWiki and Evernote. I started on Evernote, switched to Google Notebook, and recently switched back. They have an excellent iPhone client app.

RSS Reader: Google Reader. Has an iphone optimized site. Also use Gazette offline reader for iPhone, it synch's with Google Reader subscriptions.

Workout and Run Logging: Shapelink. Has a mobile optimized site. Nice mapping interface to Google maps as well.

Links: Delicious primarily, though I still have stuff on Google Bookmarks.

Books: Shelfari for tracking and rating, and Safari Books Online for technical reading.

Social:
Social Hub: Facebook - all my social content feeds hit Facebook eventually. Facebook has a fantastic iphone client. I prefer it to the web interface! If I didn't have to type on that tiny little keyboard with my big fat fingers, it would be the only interface I'd use.
Photos: Flickr (though see below)
Status Updates: Twitter + Tweetie iPhone client. Though I find Twitter a bit limiting, see Microblogging below.
Blogging: Blogger (obviously). Blogger's a little too clunky for iPhone.
Micro/Mobile blogging: Tumblr. I like Tumblr a lot. I think I may start doing small and minor technical blog posts on Tumblr in preference to Blogger. Blogger's still great for larger posts requiring more layout and formatting, but for a single picture and a little blurb, or a small status report, error message screenshot and technical solution, Tumblr is nice. Their iPhone interface is excellent.

The Photo Problem


Picasa 3 is my camera import tool and the first catalog they go into. They get sorted, picked over, and edited. The best ones, or the ones I need for blog posts get uploaded to Flickr using the Picasa2Flickr plugin.

I'm still trying to figure out the best process from there. Photos that tell a story end up here on the blog in a post. But other snapshots don't necessarily warrant a blog post (say from the Lantern Festival last night).

Facebook wants photos to be uploaded to their photo library. That's OK now I suppose as Picasa has both Facebook and Flickr buttons to make that easier.

So far I've been importing my Flickr photostream RSS feed into Facebook, but that get's slightly annoying, there's not much control over how they're displayed, and I'm getting duplicates from the feeds from the MyFlickr Facebook app. I think the solution is to turn off the wall posting of the flickr stream item. I can subscribe Tumblr to a specific RSS feed from Flickr, and subscribe Facebook to Tumblr.

Wednesday, November 19, 2008

Using NMock to Create an IDataReader for Testing Data Access Methods

If you have a simple Data Access class with a method like the one below which you need to test without depending on specific values in the database (and without embarking on a major refactoring expedition).

public decimal GetAvailableBalance(int custNumb)
{
decimal retVal = 0.00M; 
using (SqlConnection sqlConnection = new SqlConnection(_dbConnection))
{
sqlConnection.Open();
using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = "dbo.GetCustomerBalance";
sqlCommand.Parameters.AddWithValue("CustomerID", custNumb);
using (IDataReader dr = sqlCommand.ExecuteReader())
{
if (dr != null)
{
dr.Read();
retVal = Convert.ToDecimal(dr["AvailableBalance"]);
}
}
}
}
return retVal; 
}


Replace this:
sqlCommand.ExecuteReader()



With This:
public virtual IDataReader GetReader(SqlCommand cmd)
{
return cmd.ExecuteReader(); 
}



Now create a test class that inherits from the Data Access class and override that virtual method. Like so:

[TestFixture]
public class IMTTests : TransactionStore
{
Mockery mocks = new Mockery(); 
IDataReader idr = null; 

public override IDataReader GetReader(SqlCommand cmd)
{
Expect.AtLeastOnce.On(idr).Method("Read").Will(Return.Value(true));
Expect.AtLeastOnce.On(idr).Method("Dispose"); 
return idr; 
}



Now in your test, create your mock DataReader to assign to the private variable and set the specific expectations of your data mapping.

[Test]
public void TestAvailableBalance()
{
idr = (IDataReader)mocks.NewMock(typeof(IDataReader));
Expect.AtLeastOnce.On(idr).Get["AvailableBalance"].Will(Return.Value(42.00M));
Decimal amount = this.GetAvailableBalance(12345);
Assert.AreEqual(42.00M, amount); 
}

Wednesday, September 10, 2008

Compile Error in ASP.Net (error CS0103: The name 'X' does not exist in the current context)

Note: I would have liked to title this post "Microsoft Voodoo make Hulk MAD!!" but for reasons outlined in the rant below, I went with the title above.



The Problem


In an ASP.Net web project you may see one of these two compile error messages referring to a control in a page:

In the Visual Studio 2005 Output window:

"error CS0103: The name 'X' does not exist in the current context"
"error CS0117: 'XPage' does not contain a definition for 'X'"

and
In the VS.Net 2005 Compile Error List

"The name 'X' does not exist in the current context."


Where 'X' is your control variable name (like TextBox1). If you're seeing these, then you may have the same problem I did.

My problem more specifically was that I was copying files from one (working) VS.Net solution which contained one sort of web project, to another stand-alone project. I needed the new project to have a .CSProj file so our build guys could compile the site with whatever they're using. As soon as I copied the first non-static content into the new Project, the errors above started.

My Solution


The technical root cause of the problem was that there was no variable referring to the control(s) in the page object model.

More details


When I added a new page from scratch, a WebForm1.aspx.designer.CS file appeared, with the following code in it:

protected global::System.Web.UI.WebControls.TextBox TextBox1;


Hmmm . . . why did the other page not have a designer.cs file? In fact the original project I was copying from has no Designer.cs files at all.

I went back to the other (working) project and right clicked on the object referece to my control. In response to "Go to Definition" I got a message box stating:

"The definition of the object is hidden."


WTF?!?

Hidden where exactly? Visual Studio's little "Show All Files" option is greyed out. A look at the file system revealed no mystery files. This was starting to sound familiar from my long ago reading about new partial class features.
After Googling "The definition of the object is hidden" I had my answer (see references for details, specifically [1]).

It turns out that I'd stumbled into a gap between "Web Site Project" and "Web Application Project"[2]. I was attempting to manually copy files from a "Web Site" into a "Web Application". In a "Web Site Project", the compiler does some code generation for you, and hides it away in a temporary assembly stored in the location specified by HTTPRuntime.CodeGenDir.

"Web Application Projects" were rolled into VS.Net 2005 with Service Pack 1.

So anyway, throwing the textBox variable declaration into the code-behind file allowed a successful compile with a cut down version of the page. That was definitely it.

Now that I knew what I was looking for, I searched on "Converting a Web Site Project to a Web Application Project". Sure enough, that turned up [4] Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio 2005

Great . . . not only does this guide contain an exact description of the specifics of the problem, but it's a detailed guide to the solution. I still need to read a bit more of this tomorrow, but this has certainly cleared the biggest roadblock. To rub salt in the wounds, if you do the file copy from IDE window to IDE window it all happens magically, I never would have seen this problem at all:

"Visual Studio includes an option to convert pages and classes within Web application projects to use partial class declarations. Partial classes are used to separate designer-generated code from code-behind code. These designer-generated classes are stored in a separate file from the code-behind file. This conversion process causes Visual Studio 2005 to recursively examine every page, user-control, and master-page in the project, and to automatically generate a .designer.cs file for each. Visual Studio also changes the .aspx or .ascx files to use the codeBehind attribute instead of the codeFile attribute."


<BonusRant read="optional">
I get incredibly annoyed with some of these 'easy' problems. I want to be able to just look up the error message in a search engine, but it seems I always run across the same pattern of search results:

1. Often the top couple of hits are totally irrelevant sites that happened to be experiencing the same error at the time that the crawler bot visited.

2. The next hit or two are even more annoying. Typically, it's somebody who has innocently(naively) cut and pasted their error message into some forum site or support board. Their post is at the top, then there follow the useless trolls and know-it-alls who bitch about posting off topic or demand more irrelevant data. Then the whole thing either trails off, or the person solves their own problem, but doesn't post the solution. Better forums at least they put a little mark on the solution (if one has emerged).
3. After the first page or so of search results, you just get forum sites that scrape other forum sites, or tons of cross posts of the original problem to ghost-town forums.

So anyway, the moral of this story is: here's my contribution back to the internet: The error message and a solution in one troll-free page. ;-) I've seen quite a number of search hits for other technical posts here, so hopefully this helps somebody.

</BonusRant>

References


[1]The Definition of the Object is Hidden
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115127

[2]Visual Studio.Net 2005 Web Application Projects
http://msdn.microsoft.com/en-us/asp.net/aa336618.aspx

[3]ASP.Net 2.0 Hidden Files and Assemblies
http://blogs.msdn.com/daviddu/archive/2006/06/03/616324.aspx

[4]Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio 2005
http://msdn.microsoft.com/en-us/library/aa983476(VS.80).aspx

Thursday, February 21, 2008

Google Calendar, RSS, ATOM, XML, XSL, XPATH, Namespaces and Firefox Bugs

I'm not quite sure how such a simple request spiralled out of control, plunging into buckets of alphabet soup . . . but I need to write something down. By Monday morning I'll have completely forgotten what the hell I was doing today. :-)

It all started simply enough: Updating a rusty old business process.

The old process:
1. Business user creates/updates a timetable spreadsheet.
2. Business user emails spreadsheet to web team.
3. Web team converts spreadsheet to HTML cuts/pastes/styles and generally beautifies content.
4. Web page is updated with new Timetable HTML.

This of course is a very 90's way of running a website, so we were discussing alternate ways of updating and automating this process.

We settled on the idea of creating a Google Calendar for the Timetable. The interface is simple for the business users, not much different than their Outlook calendar. The owners can set up their recurring appointments, and when they need to reschedule something around an event or shift a time, it's instantly live.

On the web team side, we just needed to pull down the RSS XML from the public address of the calendar, style it with XSL, and output the same HTML table view that the users know and love.

New Process
1. Business users maintain Google Calendar
2. RSS, XSLT and CSS magically produce an HTML Timetable for the site.

And so it began . . .
I set up a public Google Calendar, entered a few test events, and downloaded the Atom feed Xml.
I posted the Atom XML on my local web server.
I opened the XML in my browsers . . Firefox shows me the feed subscription page, IE6 shows me raw XML . . . so far so good.
I created a rudimentary XSLT and inject it into the top of the XML file.


<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="wtf.xsl"?>


This displayed my "Hello XSLT" in IE6, but Firefox still shows me the default subscription page. I figure I did something dumb, or not quite standards compliant, and set off happily developing and testing in IE6 (back to this later).

Now I started putting some XPath pattern matching into my XSLT. This didn't go so well.

An RSS/Atom doc is pretty simple, it's really just a 'Channel' or 'Feed' element filled with either 'Item' or 'Entry' elements.

So I was surprised when none of my XPath worked. No combination of

/ //Entry /Entry Feed/Entry /Feed or //Feed

selected any content.
Annoyingly,
<xsl:for-each

did work, and when I did
<xsl:value-of select='name(.)'

on the current node, I got back "Entry" and "Feed".
Grrr . . .

Eventually, I decided that it had something to do with namespaces, particularly the default namespace.


<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:batch='http://schemas.google.com/gdata/batch'
xmlns:gCal='http://schemas.google.com/gCal/2005'
xmlns:gd='http://schemas.google.com/g/2005'>


Google turned up all sorts of noise around how to pull out namespaces using XSLT. I was distracted for a while trying to pull out the default namespace programatically, and tack it on to my XPath patterns. In the end, it turned out to be quite simple. I just needed to declare a prefix for the default namespace in my XSLT file:


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom">


This page pretty much solved it for me:
XPath and Default Namespace Handling;

Embarassingly, this article from back in 2001 would also have shown me the light:
http://www.xml.com/pub/a/2001/05/02/trxml.html;

Of course this all would probably would have been easier if I used a tool other than Notepad as my XML/XSLT/XPath IDE. :-)

In any case, a very simple little XSL pulls all the Entry Node contents out of an ATOM Feed:


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom">
<xsl:template match="/">
<html>
<head><title>Google Calendar Test 2</title></head>
<body>
<xsl:apply-templates select="//atom:entry"/>
</body>
</html>
</xsl:template>
<xsl:template match="atom:entry" >
<h2><xsl:value-of select="name(.)"/></h2>
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
</xsl:stylesheet>


This gave me a ugly but accurate display of the timetable info we were after . . . at least in IE.

I popped over to Firefox to take a look at it, and discovered that Firefox still displayed the same old default subscription page. I fiddled with pathing and file names for just a bit before deciding that it was something stranger than me fat-fingering a path.

It turns out that Firefox does indeed ignore your stylesheet if the phrase "RSS" or "Feed" appears in the first 512 bytes of your XML file!

Firefox 2.0 breaks client-side XSL for RSS and Atom feeds

BugzillaBug 338621 – Feed View overrides XSLT stylesheet defined in XML document

*sigh*

Ah well, I did get a good laugh out of one of the workarounds in the comments:


"The emerging workaround for this problem (which isn't new to us, since we're
using the same heuristic that IE7 betas have been using for months) is to put
in a comment ranting about the evils of sniffing web content and overriding the
desires of web developers which is long enough to move "<rss" or "<feed" out of
the first 512 bytes, since that's all we sniff.



Then, just to kick some more sand in my face, I caught this out of the corner of my eye as I was closing up my browser windows for the day:


"The Firefox pitfall

All would be good in the land of RSS and Atom if Firefox had support for the disable-output-escaping feature in XSLT but it does not.

disable-output-escaping is an obscure feature in XSLT that serves only one purpose: it processes tags that appear in other tags, such as CDATA sections. And, RSS and Atom make heavy use of CDATA sections to embed HTML code.

With disable-output-escaping, you should be able to lift the HTML tags from the feed and insert them right into the HTML page...but for Firefox. Firefox essentially ignores the instruction so it ends up displaying the raw HTML code.

There's been some debate in the Firefox community as to whether this behavior was standard compliant or not. Nevertheless it is a problem and one for which you need a solution."

Working XML: Serve friendlier RSS and Atom feeds


Then, to top it all off, I realized that there was no way we would have been able to inject that initial stylesheet declaration into Google's Atom XML anyway. We've no choice but to use either some server side script or some string parsing to help with the transformation. So we don't really need to worry about XML Namespaces or XML element names for that matter. Hmmm . . .

Ah well, I'm sure I'll be pissed about all this on Monday, but for now I've had enough. Hopefully I'll get around to posting some catchup stuff by Monday!
Have a good weekend!

File Under: Technology,

Wednesday, January 09, 2008

Upgraded Blogger Template to New Layout System.

I've just finished something that I've been putting off for a long time: upgrading my blog template to Blogger's new Layout system.

At first, it appeared to go quite smoothly. The same basic theme/template was still available, and all my widgets and hacks worked as HTML/Script blocks with no problems.

I ran into the first issue when I wanted to increase the width of the main post window. This little comment in the HTML of the template says it all:


/* Page Structure
----------------------------------------------------------- */
/* The images which help create rounded corners depend on the
following widths and measurements. If you want to change
these measurements, the images will also need to change.
*/


Happily, the HTML of the new template was nearly identical to the old one, so I just reused my wide rounded corner images from the old template.

Anyway, glad that's done. Now I can get back to posting without being annoyed by the old layout code every time I look at things.

For those of you who subscribe via feed readers and never hit the blogger pages, here's what's changed.


  • Switched the header image from the St. Croix river to Mt. Nguaruhoe.

  • Got rid of the "Days in New Zealand" counter. It'll be two years in April. That counter originally started as a countdown to keep me motivated in my moving preparations. It's not so interesting anymore.

  • Added a feed for my shared items from Google Reader.

  • Added a feed for my code snippets on Snipplr.

  • Added a "What I'm Reading" badge from my Anobii bookshelf.

  • Added a quilt of my iTunes album covers from LastFM.

  • Added a blogroll of shared feeds I read from Google Reader

  • Added a tagroll of my bookmark tags from Del.icio.us. (Although I mostly use Google Bookmarks and Google Notebook now. Unfortunately, Google bookmarks is still missing a few cool features from Del.icio.us. It's main advantage, and my reason for switching, is that it doesn't get blocked by most Surfwatch Big Brother programs)

Tuesday, March 20, 2007

How to Undisable the Use of USB Storage Devices

In a managed desktop environment, if a USB device fails to install because XP can't locate the drivers, chances are that The Man has messed with the permissions on USBStor.inf and/or USBStor.pnf

Just reverse whatever has been done from this article (requires admin privileges of course):

How to Disable the Use of USB Storage Devices.
http://support.microsoft.com/kb/823732

Wednesday, March 14, 2007

.Net CLR Performance Counters Don't Appear in Perfmon

This took a while to figure out . . . I needed to use the .Net Memory counters to watch the heap sizes and garbage collections. Unfortunately, none of them appeared in Perfmon under Performance Objects.

I looked up the old standby on "How to Manually Rebuild Performance Counter Library Values"

I wasn't quite willing to do all of the registry pecking and ripping needed to do that rebuild but I checked out the keys mentioned and tried running LODCTR \R on the .Net CLR ini file. That reported that they were already installed. :-

So I checked in on the registry entries under Services . . . HKLM\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance

Imagine my surprise when I saw this value:

Disable Performance Counters = 1

Setting that to 0 brought the counters back as expected.

I blame big brother for this one, but it turns out that windows will make this setting if a counter fails some tests at load time.
Disable Performance Counters

Although you can set Perflib not to disable on fail:
Perflib Configuration Flags

Thursday, February 22, 2007

Mail-to-Blogger Post Tip Number 1

Use (hash)end at the end of the post content to keep the email auto-footer from posting.

Sunday, November 12, 2006

Synching GMail with Mobile Phones

Cool, I've been looking for something like this for a while. This plugin lets you pull an iCal into Outlook. Then your mobile phone software, (like Nokia PCSuite) should be able to do the rest. I'll post the results (along with lots of catch-up stuff) later.

Incorporate Google Calendar into Outlook.

File Under: Technology,