This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First, make sure our browser supports HTML 5 local storage | |
if (typeof(localStorage) == 'undefined' ) | |
{ | |
alert('Your browser does not support HTML5 localStorage. Try upgrading.'); | |
} | |
else | |
{ | |
try | |
{ | |
// saves to the database using key/value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataSet ds = GetDataSetFromStoredProc("stored_proc_name", new SqlParameter("@parameter_name", value_id)); | |
var retItems = from dstable in ds.Tables[0].AsEnumerable() | |
select new ClassThing() | |
{ | |
PrimaryKeyId = dstable.Field<int>("some_column_name") | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Security.Cryptography; | |
/// Hashes an email with MD5. Suitable for use with Gravatar profile | |
/// image urls | |
public static string HashEmailForGravatar(string email) | |
{ | |
// Create a new instance of the MD5CryptoServiceProvider object. | |
MD5 md5Hasher = MD5.Create(); | |
// Convert the input string to a byte array and compute the hash. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Format: | |
http://www.gravatar.com/avatar/{md5 hash} | |
Example: | |
http://www.gravatar.com/avatar/73543542128f5a067ffc34305eefe48a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compute the hash | |
string hash = HashEmailForGravatar(email); | |
// Assemble the url and return | |
return string.Format("http://www.gravatar.com/avatar/{0}", hash); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// If the given model field has validation errors, this will emit the given CSS class name | |
/// </summary> | |
/// <typeparam name="TModel"></typeparam> | |
/// <typeparam name="TProperty"></typeparam> | |
/// <param name="htmlHelper"></param> | |
/// <param name="expression"></param> | |
/// <param name="cssClassToEmit"></param> | |
/// <returns></returns> | |
public static MvcHtmlString ValidationCSSClassFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string cssClassToEmit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="email_tip" class="tip <%: Html.ValidationCSSClassFor(m=>m.Email, "error") %>" style="display: none;float: left;"> | |
<%: Html.ValidationMessageFor(m=>m.Email) %> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shoppingLists = from user in Users | |
join listUsers in ShoppingListUsers | |
on user.UserId equals listUsers.UserId | |
join lists in ShoppingLists | |
on listUsers.ShoppingListId equals lists.ShoppingListId | |
where user.UserId == userToFind.UserId | |
select lists; | |
return shoppingLists; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin transaction; | |
declare @deletedIds table ( id int ); | |
delete t1 | |
/* Notice this next line is using the 'deleted' pseudo table: */ | |
output deleted.id into @deletedIds; | |
from table1 t1 | |
join table2 t2 | |
on t2.id = t1.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use transfer effect | |
$("#txtProduct").effect("transfer", { to: $("#test") }, 1000); |