Welcome on
SoftLion.com
 
Softlion's web development tools
Show my IP: shows your real IP
Verify & validate XML and XHTML: verify, validate and locate errors in your XML and XHTML against XSD schemas
XML Pretty Print: pretty print your XML online
Online regular expression tester: build and validate your regular expression online
 
Currently interested in (among lots of other things) : Chumby

Today I present an easy to use open source gravatar control.
To show a gravatar logo of one of your visitor you'll need only the visitor's email.

 

I took the source code from the reference implementation advertised on Gravatar from freshclickmedia (see references at the bottom of this article), updated it to match the new gravatar API, and among other things fixed the ViewState implementation.

 

Basic usage
1) In your project add a reference to the assembly FreshClickmedia.Web.dll
2) At the top of your aspx or ascx page add:
<%@ Register TagPrefix="fcm" Assembly="FreshClickmedia.Web" Namespace="FreshClickMedia.Web.UI.WebControls" %>
3) In your page add this tag where you want the logo to appear:
<fcm:Gravatar ID="GravatarImage" runat="server" Email="thisemaildoesnotexist@thisemaildoesnotexist.com" />

 

References
Gravatar: http://www.gravatar.com/
Original ASP.NET control from freshclickmedia: http://www.freshclickmedia.com/blog/2008/06/aspnet-gravatar-control-update-full-source-included/

 

Downloads
.NET Assembly only
Full source code with example web site

 

Examples

My email address, size of 80 pixels:
<fcm:Gravatar ID="Gravatar1" runat="server" Email="putexistingemailhere@putexistingemailhere.com" OutputGravatarSiteLink="true" Size="80" />
Gravatar

No email address, with default image (absolute url) specified:
<fcm:Gravatar ID="Gravatar2" runat="server" Size="80" DefaultImageUrl="http://farm3.static.flickr.com/2375/2552064340_192825f989_o.jpg" />
Gravatar

Email address not associated with Gravatar, with no default image (identicon):
<fcm:Gravatar ID="Gravatar3" runat="server" Email="thisemaildoesnotexist@thisemaildoesnotexist.com" />
Gravatar

Email address not associated with Gravatar, with no default image (wavatar):
<fcm:Gravatar ID="Gravatar4" runat="server" Email="thisemaildoesnotexist@thisemaildoesnotexist.com" DefaultImageType="Wavatar" />
Gravatar

Email address not associated with Gravatar, with no default image (Monsterid):
<fcm:Gravatar ID="Gravatar5" runat="server" Email="thisemaildoesnotexist@thisemaildoesnotexist.com" DefaultImageType="Monsterid" />
Gravatar 

 

...

Transfering rows from a development database to a production database can quickly become a nightmare.
To avoid this you should think your data model to deal with this new constraint: each row must be uniquely identified by a value which does not change in time and can be recomputed in a similary table in another database at anytime.

 

This unique value can be a hash. A hash is an asymetric cryptography function which always generates the same value when the same input is specified, and has a 99,9% chance to generate a different values with different inputs.


That means to generate our small hash to identify a row, we should find a primary key on our table which does not depend on an identity column. We can not use variable date fields nor uniqueidentifier fields as they are generated on row creation and will be different if we create a row with the same data on another database. This primary key can be a composite string key made of parts of the other table columns.

 

Using the HashBytes function with the SHA1 hash function in SQL 2005 generates a binary(20) result. With SQL 2000 you may use the checksum() function.

 

Example:

CREATE TABLE [dbo].[ITEM](
    [ITEMID] int IDENTITY(1,1) NOT NULL,
    [NAME] nvarchar(50) NOT NULL,
    [DESCRIPTION] nvarchar(200) NOT NULL,
    [HASH] AS (hashbytes('SHA1',[NAME]+[DESCRIPTION])),
CONSTRAINT [PK_ITEM_ITEMID] PRIMARY KEY CLUSTERED
(
    [ITEMID] ASC
),
CONSTRAINT [IX_ITEM_HASH] UNIQUE NONCLUSTERED
(
    [HASH] ASC
))
 

Limitation: HashBytes input string is limited to 8000 bytes.
Tip: you may use the undocumented function master.dbo.fn_varbintohexstr(binary hash value) to convert the binary result to a string prefixed with 0x.

...

This post is empty, don't read it.
Too late ?
Anyway you are already loosing time browsing Internet.

See ya  Tongue out

...