February 06, 2008

Adding a unique digg button per post using Blogger

Adding a digg button to your blog on blogspot is easy, and users can digg the blog, or even digg an individual post, provided they were drilled into a specific post. But what if you want your readers to digg any specific post from your main page? If you have a following, that's probably where they'll read it from, and a digg button on your main page will only take them to digging the blog in general. Basically, you'll want to have a button inside each posting with a digg_url that is specific to that post.

Here's a way I found to get it to work:

Go to your blog's admin page and select the Template tab
Select Edit HTML
Make sure "Expand Widget Templates" is checked
Look for the <div class="post-footer"> div tag
Inside that tag, add your digg button code
For the digg_url value us e <data:post.url/>(This template variable holds the actual url of each individual post)
Note: The code window will encode the quotes.

Here's some sample button code and more digg integration info if you need it.

...Of course if you use it, you have to digg me :)

<!-- digg button with post-specific url added - Dan Shultz -->
<script type='text/javascript'>digg_url = '<data:post.url/>'; digg_title = '<data:post.title/>'; digg_bodytext = ''; digg_skin = 'compact'; digg_window = 'new'; digg_media = 'image'; digg_topic = 'comics_animation';
</script>
<script src='http://digg.com/tools/diggthis.js' type='text/javascript'/>
<!-- end digg button code -->

Share |

February 01, 2008

XMLSerialization & null/empty elements

I recently ran into an issue where an application was serializing a .NET object and returning the XML, but not returning elements where the properties were null. The consuming client expected every element in the schema to be returned, so we needed to come up with the best way to generate XML containing all elements & nodes regardless of whether they contained data.

The first solution was to simply decorate the property with

[XmlElement(IsNullable=true)]

which makes sure the element is always generated. The resulting xml element contains the attribute xsi:nil="true" when it is null. That works just fine, but an even simpler solution is just to initialize the private variable behind the property to string.empty. That ensures that the property was always at least an empty string, rather than null. To the XmlSerializer, empty string means generate element. But if you require that the resulting XML has to include all properties, even true nulls, then decorating potentially null properties with the XmlElement IsNullable Attribute is the way to go.

Share |

January 17, 2008

BMI Calculator

BMI Calculator


- Height
- Weight
- BMI



Share |

January 10, 2008

.NET Tips and Tricks Open Spaces

The late session Thursday, I tried out Open Spaces for the first time - Sara Ford, who does the Visual Studio tip of the day ran a session on Visual Studio tips and tricks. She has a vast collection of tips, obscure keycodes and showed some of the coolest/most popular ones. They're all on her blog, but here are some of the ones I was unaware of and will incorporate into my daily routine:

Enabling Guidelines - registry edit that allows you to drag guidlines into the vs text editor

Under Tools.. Options.. Text Editor.. All languages.. General uncheck "Apply copy and cut if no blank lines" checkbox
This DOESN'T overwrite what's on your clipboard if you accidentally cut or copy twice by accident before you paste, and your cursor happens to not have anything selected. I do this all the time and I thought it was just me.

Ctrl+w = select current word

Right click find window to make it dockable.

Right click on file tab.. open containing folder opens win explorer to current file's folder.
Right click on file tab.. close all but this closes all other windows.
Right click on file tab.. full path gets the full file system path to that file.

ctrl-tab allows you to tab to all open files and windows windows w arrow key.

ctrl-alt-downarrow pops arrow on tab window to show additional unshown files.

Options.. startup, can specify new start page

ctrl-f2 goes to navigation dropdown + tab goes to 2nd drop down showing methods.

Any file menu + ctrl tab goes to first item in the standard toolbar

Customize toolbar window looks modal but is not.

LEFT Shift alt tabs to the first button in a toolwindow's toolbar (like schemas, solution windows)

alt-minus (with floating window active) and you can move it around with the up-down keys. I'm not sure how much I'll use it, but it gave me a chuckle.

Anyway, these are all available on her blog, but it was nice to have a session and get the cream of the crop. She also has a tip of the day gadget for Vista.

This was the only Open Spaces session I got to, but it's a cool addition to the conference sessions.

Share |

CodeMash FaceBook development session notes

Uses FBML, FBJS

Create FaceBook Developer acct
Developer mode

Submit application to attract users
Built in App statistics
Can host on your own server

REST API
Api_key, v, Format, Method, UIDs, Fields, Call_id, sig
Session_key (gotten by you from user)

Get session key by:
User can either log in to your app
Or user installs your app

Can use FQL (subset of t-sql, no joins) to access user data.

Viral Distribution
Notifications

FBML: No <EMBED> <fb:profile-pic> + uid displays user profile pic, <fb:multi-friend-input> renders auto-complete friends text box (used commonly)

client langs PHP, Java unofficial:Actionscript, Ruby

Share |