Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
public class HandleRecordNotFoundAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var viewResult = filterContext.Result as ViewResult;
if (viewResult != null && viewResult.ViewData.Model == null)
{
filterContext.Result = new ResourceNotFoundResult();
filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
map.connect '/somethin/:email', requirements => { :email => / <insert your favorite email regex here> / }
"{\"issue\":[{\"@priority\":\"1\",\"@type\":\"Task\",\"@state\":\"Fixed\",\"@subsystem\":\"No subsystem\",\"@id\":\"DCVR-1\",\"@fixedVersion\":\"\",\"@projectShortName\":\"DCVR\",\"@reporterName\":\"ruslan.isakiev\",\"@fixedInBuild\":\"Next build\",\"@commentsCount\":\"0\",\"@numberInProject\":\"1\",\"@summary\":\"Show coverage results in unit test runner's window\",\"@created\":\"1256724558540\",\"@updated\":\"1257780483529\",\"@historyUpdated\":\"1257780483532\",\"@resolved\":\"1257769772458\",\"@votes\":\"0\",\"links\":null,\"attachments\":null},{\"@priority\":\"1\",\"@type\":\"Exception\",\"@state\":\"Fixed\",\"@subsystem\":\"Submitted exceptions\",\"@id\":\"DCVR-2\",\"@fixedVersion\":\"\",\"@projectShortName\":\"DCVR\",\"@reporterName\":\"ruslan.isakiev\",\"@fixedInBuild\":\"Next build\",\"@commentsCount\":\"0\",\"@numberInProject\":\"2\",\"@summary\":\"Exception : An exception has occurred during action 'OpenSnapshot' execution. Sample exception\",\"@description\":\"dotCover 1.0 Version=1.0.0.0, Built=2
{"issue":[{"@priority":"1","@type":"Task","@state":"Fixed","@subsystem":"No subsystem","@id":"DCVR-1","@fixedVersion":"","@projectShortName":"DCVR","@reporterName":"ruslan.isakiev","@fixedInBuild":"Next build","@commentsCount":"0","@numberInProject":"1","@summary":"Show coverage results in unit test runner's window","@created":"1256724558540","@updated":"1257780483529","@historyUpdated":"1257780483532","@resolved":"1257769772458","@votes":"0","links":null,"attachments":null},{"@priority":"1","@type":"Exception","@state":"Fixed","@subsystem":"Submitted exceptions","@id":"DCVR-2","@fixedVersion":"","@projectShortName":"DCVR","@reporterName":"ruslan.isakiev","@fixedInBuild":"Next build","@commentsCount":"0","@numberInProject":"2","@summary":"Exception : An exception has occurred during action 'OpenSnapshot' execution. Sample exception","@description":"dotCover 1.0 Version=1.0.0.0, Built=2009-11-02T12:21:25, Configuration=“Full PublicMode VS0900”\nAn exception has occurred during action 'OpenSnapshot' execution.
public class AutoFilterActionInvoker: ControllerActionInvoker
{
protected override FilterInfo GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
var filters = base.GetFilters(controllerContext, actionDescriptor);
filters.ResultFilters.Add(new CustomBehaviorAttribute());
return filters;
}
_routeConventions.MapAction("Create").WithNoParameters().ToCustomUrl("/new").ConstraintToVerb(HttpVerbs.Get);
[Subject("Encoding Enums")]
public class when_encoding_an_object_that_contains_an_enum
{
Establish context = () =>
{
IEnumerable<IDataReader> readers = new List<IDataReader> { new JsonReader(new DataReaderSettings(), "application/.*json") };
IEnumerable<IDataWriter> writers = new List<IDataWriter> { new JsonWriter(new DataWriterSettings(), "application/.*json") };
codec = new DefaultCodec(new RegExBasedDataReaderProvider(readers), new RegExBasedDataWriterProvider(writers));
public class a_response_that_contains_umlats
{
Because of = () =>
{
var http = new HttpClient();
http.Request.Accept = HttpContentTypes.ApplicationJson;
response = http.Get("https://api.github.com/users/thecodejunkie");
describe('Farting', function () {
describe('when shaking the phone with my hands', function () {
it('a farting sound should appear', function (done) {
// TODO: Implement Fart
done();
});
});
function logger(options) {
if ('object' == typeof options) {
options = options || {};
} else if (options) {
options = { format: options };
} else {
options = {};
}