Skip to content

Instantly share code, notes, and snippets.

David De Sloovere DavidDeSloovere

Block or report user

Report or block DavidDeSloovere

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View WebApiConfigCamelCaseJson.cs
public static class WebApiConfig
public static void Register(HttpConfiguration config)
// just camel case
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
// or camel case plus nicer formatting
var json = config.Formatters.JsonFormatter;
json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
DavidDeSloovere / WebApiConfigRemoveXmlFormatter.cs
Last active Aug 29, 2015 — forked from beyond-code-github/WebApiConfig.cs
Remove the XML formatter so content is always returned as JSON.
View WebApiConfigRemoveXmlFormatter.cs
public static class WebApiConfig
public static void Register(HttpConfiguration config)
var xmlFormatter = config.Formatters.XmlFormatter;
DavidDeSloovere / AutoMapperConfiguration.cs
Created Aug 20, 2014
AutoMapperConfiguration Put AutoMapperConfiguration.Configure(); in global.asax
View AutoMapperConfiguration.cs
public static class AutoMapperConfiguration
public static void Configure()
Mapper.CreateMap<OriginalEntity, DtoEntity>()
.ForMember(dest => dest.EntityId, source => source.MapFrom(s => s.Id));
DavidDeSloovere / PrepResourceFilesForTranslator.bat
Created Feb 26, 2014
This ScriptCS code copies files into a folder while renaming them, and then compresses them into a zip file.
View PrepResourceFilesForTranslator.bat
ECHO ---
ECHO This command needs scriptcs (see
ECHO If it is not installed you will get an error
ECHO ---
scriptcs PrepResourceFilesForTranslator.csx
ECHO ---
DavidDeSloovere / gist:6277610
Last active Dec 21, 2015
System.Net.HttpResponseMessage set custom status code like 429
View gist:6277610
var response = new HttpResponseMessage
StatusCode = (HttpStatusCode)429,
ReasonPhrase = "Too Many Requests",
Content = new StringContent(string.Format(CultureInfo.InvariantCulture, "Rate limit reached. Reset in {0} seconds.", data.ResetSeconds))
response.Headers.Add("Retry-After", data.ResetSeconds.ToString(CultureInfo.InvariantCulture));
actionContext.Response = response;
DavidDeSloovere / JsonNetResult
Created Jun 1, 2013
JsonNetResult for ASP.NET MVC - correct formatting of dates and camel cased properties Got most of the code from Stack Overflow.
View JsonNetResult
using System;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
public class JsonNetResult : JsonResult
public override void ExecuteResult(ControllerContext context)
DavidDeSloovere / CopyChmLocalAndOpen.ps1
Created Jan 4, 2013
Open up an old school .CHM help file from a network path. Put the Powershell in the folder of the .CHM file and any user can launch the help file via right-click on the .PS1 and selecting 'Run with Powershell'. (Set-ExecutionPolicy might need to be set first)
View CopyChmLocalAndOpen.ps1
$tempfolder = $env:TEMP
$chmfile = Get-ChildItem | Where-Object {$_.Extension -match "chm"}
"Copying to local temp folder: $tempfolder"
Copy-Item $chmfile $tempfolder
"Opening $chmfile"
Start-Process $tempfolder\$chmfile
DavidDeSloovere / gist:1893621
Created Feb 23, 2012
Sample CacheAttribute for ASP.NET Web Api - i'm not saying this is the best way
View gist:1893621
namespace ProjectName.WebApi.Infrastructure
using System;
using System.Net;
using System.Net.Http.Headers;
using System.Web.Http.Filters;
public class CacheAttribute : ActionFilterAttribute
public CacheAttribute()
You can’t perform that action at this time.