Skip to content

Instantly share code, notes, and snippets.

@azcoov
azcoov / MvcSiteMap.cs
Created March 21, 2011 05:02
Render a sitemap in asp.net mvc
using System;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Web.Mvc;
using System.Xml;
using System.Xml.Linq;
namespace MvcSiteMap.Controllers
{
[HandleError]
@azcoov
azcoov / checkoverflow.cs
Created March 17, 2011 02:22
Check for an Overflow Exception
try
{
checked
{
int x = int.MaxValue;
int++;
}
}
catch (OverflowException ex)
{
@azcoov
azcoov / weatherchecker.vb
Created March 16, 2011 03:33
example weather checker
Imports System.Web.Mvc
Namespace Controllers
<HandleError> _
Public Class HomeController
Inherits Controller
Public Function Index() As ActionResult
Return View()
End Function
@azcoov
azcoov / UpdateStatistics.sql
Created March 14, 2011 15:42
Update Statistics for all tables
create sp_UpdateStatistics
as
/*
This procedure will run UPDATE STATISTICS against
all user-defined tables within this database.
*/
declare
@tablename varchar(255),
@tablename_header varchar(255)
@azcoov
azcoov / MortgagePaymentCalculator.vb
Created March 12, 2011 03:09
POS / 408 MortgagePaymentCalculator
'
' File: MortgagePaymentCalculator.vb
' Author: Billy Coover
' Date: March 11, 2011
'
' Change request 16 from SR-mf-003. Create a VB.NET program that calculates and displays the monthly
' payment for a $200,000 loan at 5.75% interest for 30 years
'
' Quality Control
' Version 0 | 03/11/2011 | Write the program in VB.Net (not Web based) using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year term. Display the mortgage payment amount. Insert comments to document the program. There is No Requirement for the user to enter values.
@azcoov
azcoov / mortgagecalc.vb
Created March 10, 2011 03:39
Mortgage Calc example
Class Mortgage
Private Property LoanAmount() As [Decimal]
Get
Return m_LoanAmount
End Get
Set
m_LoanAmount = Value
End Set
End Property
Private m_LoanAmount As [Decimal]
@azcoov
azcoov / ipaddress.cs
Created February 19, 2011 17:17
MVC Get the users IP Address
string SourceIP = string.IsNullOrEmpty(Request.ServerVariables["HTTP_X_FORWARDED_FOR"]) ?
Request.ServerVariables["REMOTE_ADDR"] :
Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
@azcoov
azcoov / call-toast.js
Created February 1, 2011 04:27
calling the toaster
$("#viewerror").ajaxError(function (e, xhr, ajaxOptions, thrownError) {
toast(xhr.responseText);
});
@azcoov
azcoov / toast.js
Created February 1, 2011 04:26
toast example
function toast(message) {
$(".message-info").html(message);
if ($(".message-info").html().length > 0) {
$(".notification-bar-container").show('slide', { direction: 'up' }, 1000).delay(2500).hide('slide', { direction: 'up' }, 1000);
}
}
@azcoov
azcoov / GravatarExtension.cs
Created January 24, 2011 05:34
UrlExtension to render Gravatars
using System;
using System.Security.Cryptography;
using System.Text;
using System.Web.Mvc;
public static class GravatarExtension
{
public static string Gravatar(this UrlHelper url, string emailAddress, int size)
{
var baseUrl = "http://www.gravatar.com/avatar/{0}?s={1}";