Skip to content

Instantly share code, notes, and snippets.

View mxmissile's full-sized avatar
🎯
Focusing

Travis mxmissile

🎯
Focusing
View GitHub Profile
public class FubuRegistry : Registry
{
public FubuRegistry()
{
var htmlConventionLibrary
= new HtmlConventionLibrary();
var conventions
= new OverrideHtmlConventions();
htmlConventionLibrary.Import(conventions.Library);
For<HtmlConventionLibrary>().Use(htmlConventionLibrary);
using (var imageFactory = new ImageFactory())
{
var layer = new ResizeLayer(new Size(800, 500), null, ResizeMode.Stretch);
imageFactory.Load(ms)
.Resize(layer)
.Format(ImageFormat.Jpeg)
.Quality(90)
.Save(path);
}
public class Impersonation : IDisposable
{
public Impersonation(string username, string password, string domain)
{
try
{
IntPtr tokenHandle; // = IntPtr.Zero;
Int32 ret;
if (
public class MyViewEngine : RazorViewEngine
{
/// <summary>
/// default ~/views
/// </summary>
/// <param name="startingPath"></param>
public MyViewEngine(string startingPath)
{
var formats = new[]
{
@mxmissile
mxmissile / gist:8040449
Created December 19, 2013 15:00
over engineered?
public class GetContact : IQuery<Contact>
{
public int Id {get;set;}
}
public class GetContactHandler : IQueryHandler<GetContact,Contact>
{
public Contact Handle(GetContact request)
{
return contact from db;
public struct DateTimeSpan
{
private readonly int years;
private readonly int months;
private readonly int days;
private readonly int hours;
private readonly int minutes;
private readonly int seconds;
private readonly int milliseconds;
public ActionResult RemoveCategory(int id)
{
var cat = _db.Get<Category>(id);
if(cat == null)
return HttpNotFound();
...
}
@mxmissile
mxmissile / gist:7789048
Created December 4, 2013 15:08
Retrieve the Category in the Controller or the Handler?
public class RemoveCategory : ICommand
{
public Category Category {get;set;}
}
public class RemoveCategoryHandler : ICommandHandler
{
public void Handle(RemoveCategory message)
{
//remove category
@mxmissile
mxmissile / gist:7451301
Created November 13, 2013 15:49
FilePathResult that I use with Impersonation
public class BigAssImpersonatingFileResult : FilePathResult
{
public BigAssImpersonatingFileResult(string fileName, string contentType)
: base(fileName, contentType)
{
}
protected override void WriteFile(HttpResponseBase response)
{
using (new Impersonation())
@mxmissile
mxmissile / gist:6907624
Created October 9, 2013 20:17
Custom Fixie convention using Fabricator to hydrate objects.
public class CustomConvention : Convention
{
public CustomConvention()
{
Classes
.NameEndsWith("Tests");
Methods
.Where(method => method.IsVoid());