Skip to content

Instantly share code, notes, and snippets.

View chaoaretasty's full-sized avatar

Chao chaoaretasty

View GitHub Profile
@chaoaretasty
chaoaretasty / Readme
Created January 24, 2012 18:07
Timespan model binding for MVC3
=========================
Based on the Simple Time Picker Modelbinder by Sergi Papseit Valls
http://www.sharpedgesoftware.com/Blog/2011/06/08/simple-time-picker-model-binder-for-aspnet-mvc-3-and-how-to-save-it-to-sql-ce-4-using-ef-41
=========================
I tried the modelbinder above but found a few issues with it including not being able to deal with blank options or partially filled out TimeSpans. This is my current version of it (it is a bit messy I warn you).
This is designed to bind to nullable TimeSpans, I haven't tried it with non-nullable ones, but you can overcome this by adding a [Required] attribute. The features are:
@chaoaretasty
chaoaretasty / WebAPI HttpContext for Autofac
Created October 14, 2013 16:53
Hackily enable HttpContext in WebAPI and Autofac
/*
While generally using HttpContext, and all of the related properties such as
Cookies and Session, in WebAPI is not the right way sometimes it needs to be
done, especially when migrating existing code before doing a full rewrite but
could happen in any legacy MVC project you want to bring WebAPI into.
When using Autofac there is the AutofacWebTypesModule which allows you to resolve
these dependencies, all of which come from resolving HttpContextBase.
WebAPI doesn't provide HttpContext directly but if hosted in IIS rather than
@chaoaretasty
chaoaretasty / gist:df175d568d8ed555adc8
Last active August 29, 2015 14:02
Spicy chicken marinade

I chucked some stuff together and it worked quite well. This is me trying to attach some rough amounts to it, probably quite badly.

Warning this is very hot

##Wet ingredients

  • 3 tablespoons Reaper hot sauce
  • 3 tablespoons soy suace
  • 3 teaspoons honey
  • 2 teaspoons balsamic vinegar
@chaoaretasty
chaoaretasty / gist:811d347039c2278d84ca
Created October 14, 2014 00:21
Shepherd's Pie Recipe
500 grams mince
Oil for frying
2 large onions
3 large carrots
400 ml Beef stock (Knorr rich beef stock pot)
3-4 tablespoons Worcestershire sauce
3 heaped teaspoons cornflour
1 whole star anise
4 small dried chillies
Duck breasts:
Score then lightly oil and rub with equal parts salt, black pepper and Szechuan pepper. Leave for 30-120 minutes.
Heat oil in frying pan on high. Cook the duck breasts for 4 minutes on the fat side and 3 minutes on the other side.
Leave to rest while making the sauce, rest for at least 5 minutes.
Sauce:
Zest and juice from 1 orange
3-4 tablespoons soy sauce
@chaoaretasty
chaoaretasty / Sortable.js
Created March 16, 2015 18:24
IE8 fixing for Sortable.js
/**!
* Sortable
* @author RubaXa <[email protected]>
* @license MIT
*/
(function(factory) {
"use strict";
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Reflection;
using System.Threading;
using Dapper;
using Hangfire;
using Hangfire.Annotations;
using Hangfire.Logging;
using Hangfire.Server;
0eNrlXNuS4jYQ/Rc/JpCyJFu2qSSfkKe8paYoA4JRrbGJL7M72Zp/j4QBG1lCLexhtmZfdpZhfNzdp1s6un73VlnDDiXPa2/x3ePrIq+8xT/fvYrv8jSTv6tfD8xbeLxme2/m5elefipTnnlvM4/nG/bNW6C3mfWRtKx5lrHydV43Zcnq3uP47WnmsbzmNWft648fXpd5s1+xUuBfUKpmVdVpzYtcIB+Kih//K94pYOZY/N2r+Jm8SXsUDAzDIGeImSeCkbO1/LKS3yL5T8k2fQO5+BT0XiY/I188yst1w+v2s/RuVzKW256k1w+KsLzpPCEdDcWqOBRlPfTDb92IWzfqssiWK/acvvCilH9xfs2+2LBlsV0WB1a2EZGxros6zZZZseNVzdfLoqkPTb208Hv+87k06shuCyNTqi6bYxyBUP1HznAGPrRxpSoBVoK0cQ5AGYNC54zBikERGhBvyBj1SZrAXAkBKXOunjtyxndhByGYzbTXdPD6ec9kcq2L/YrnaS1MGjhwKt3ot1CYs+Fla02bDhp/OlSZoxt+MX3Ly0qToy+8rBvxmy4rjn8xZ+n6WaZ7xSRMm++pbE9FmvVi5P0qnjTl/21sp+QnIpwzDxu/N7Uq0XX5CQ9uBhsnv4WGeGN9vLc8q1lp6F5MAfjLO/reyHiiXn/zBK82ZPI4vrxsm1b1nOcVK4WFmsb07GqouhrcLpVLXt1IK1sr2uWTrJtif0jLIyML73e3VjGxNIOmMCXQMM0fGCddFzFhrGJDLGTM7mq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