Skip to content

Instantly share code, notes, and snippets.

View juristr's full-sized avatar

Juri Strumpflohner juristr

View GitHub Profile
@juristr
juristr / gist:3973479
Created October 29, 2012 13:15
Programmatic GZip Action Filter for ASP.net MVC3
public class GZipCompressionGlobalActionFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
string acceptEncoding = filterContext.HttpContext.Request.Headers["Accept-Encoding"];
if (string.IsNullOrEmpty(acceptEncoding)) return;
acceptEncoding = acceptEncoding.ToUpperInvariant();
@juristr
juristr / jekyll_github.md
Created October 24, 2012 21:37
Jekyll Blogging Tips and Tricks

Setup Windows

If you need to update jekyll on windows, pay attention that you might get an ETIMEDOUT error. This is due to a proxy or firewall. In such case the --http-proxy option has to be used

gem update jekyll --http-proxy http://user:pwd@proxy-server:port

Writing Drafts using a separate Git Branch

@juristr
juristr / gist:3812508
Created October 1, 2012 15:28
AutoMapper Bidirectional Mapping Extension
public static class AutoMapperExtensions
{
public static void Bidirectional<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
{
Mapper.CreateMap<TDestination, TSource>();
}
}
@juristr
juristr / IdentityStub.cs
Created August 10, 2012 05:47
Some helper classes to create a fake principal with roles
public class IdentityStub : IIdentity
{
private readonly string _name;
private readonly string _authenticationType;
private readonly bool _isAuthenticated;
public IdentityStub(string name, string authenticationType, bool isAuthenticated)
{
_name = name;
_isAuthenticated = isAuthenticated;
@juristr
juristr / SmellyCodeReview.cs
Created December 31, 2010 08:25
Taken from a #smellycode post, just to demonstrate the usage fo gist in code reviews
public Account ReadCompleteAccountByADUsernameAndServiceUID(string adUsername, string serviceInstanceUID)
{
    IList<Address> addresses;
    IList<Contact> contacts;
 
//Attention, directly instantiating an object within the method may potentially create
//problems when doing testing 'cause its dependency cannot be mocked out.
    MasterDataBL masterDataBL = new MasterDataBL();
 
    Account result =  AccoDao.ReadCompleteAccountByADUsernameAndServiceUID(adUsername, serviceInstanceUID, ConnectionString.Master, out addresses, out contacts);