Skip to content

Instantly share code, notes, and snippets.

View robertgreiner's full-sized avatar

Robert Greiner robertgreiner

View GitHub Profile
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public class LoggingAttribute : InterceptAttribute
{
public override IInterceptor CreateInterceptor(IProxyRequest request)
{
return request.Kernel.Get<LoggingInterceptor>();
}
}
public class LoggingInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
try
{
Console.WriteLine("Start");
invocation.Proceed();
Console.WriteLine("Success!");
}
public class AppModule : NinjectModule
{
public override void Load()
{
Bind<ITaxType>().To<SalesTax>();
}
}
public class SalesTax : ITaxType
{
public virtual decimal Calculate(decimal subTotal)
{
return Math.Round(subTotal * 1.0825m, 2, MidpointRounding.ToEven);
}
}
public interface ITaxType
{
decimal Calculate(decimal subTotal);
void ErrorMethod();
}
@robertgreiner
robertgreiner / tipster.rb
Created January 12, 2012 17:01
Generate an HTML report that gives information on the risk of a local git commit.
require 'tipster'
Tipster.new('/path/to/repository').html_report
@model MVC3Layouts.Models.Person
@{
ViewBag.Title = "Index";
Layout = "~/Views/Home/_Layout.cshtml";
}
<h2>Index</h2>
<h3>Person Information</h3>
public class HomeController : Controller
{
private Person p = new Person();
public ActionResult Index()
{
p.FirstName = "Robert";
p.LastName = "Greiner";
p.TwitterHandle = "@robert_greiner";
return View(p);
public class Person {
public string FirstName { get; set; }
public string LastName { get; set; }
public string TwitterHandle { get; set; }
}
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
</head>
<body>
<h1>This is the Home Layout page!</h1>
<div>
@RenderBody()
</div>