Skip to content

Instantly share code, notes, and snippets.

View cecilphillip's full-sized avatar

Cecil Phillip cecilphillip

View GitHub Profile
@haacked
haacked / ServiceResolverAdapter.cs
Created March 11, 2012 19:34
ServiceResolverAdapter: Allows you to use the ASP.NET MVC DependencyResolver for ASP.NET Web API
public class ServiceResolverAdapter : IDependencyResolver
{
private readonly System.Web.Mvc.IDependencyResolver dependencyResolver;
public ServiceResolverAdapter(System.Web.Mvc.IDependencyResolver dependencyResolver)
{
if (dependencyResolver == null) throw new ArgumentNullException("dependencyResolver");
this.dependencyResolver = dependencyResolver;
}
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@sixeyed
sixeyed / IHttpActionResultExtensions.cs
Created April 8, 2014 12:45
Wrapping WebApi IHttpActionResult to expose the response message to controllers
using SampleApi.Results;
using System;
using System.Net.Http;
using System.Web.Http;
namespace SampleApi
{
public static class IHttpActionResultExtensions
{
public static IHttpActionResult With(this IHttpActionResult inner, string responsePhrase = null, Action<HttpResponseMessage> responseAction = null)
@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@davidfowl
davidfowl / dotnetlayout.md
Last active November 13, 2024 13:19
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@ericelliott
ericelliott / essential-javascript-links.md
Last active November 8, 2024 17:29
Essential JavaScript Links
@mahizsas
mahizsas / async-mediator-pipeline.cs
Last active December 29, 2016 21:18
Autofac implementation for mediator pipeline
public class AsyncMediatorPipeline<TRequest, TResponse> : IAsyncRequestHandler<TRequest, TResponse> where TRequest : IAsyncRequest<TResponse>
{
private readonly IAsyncRequestHandler<TRequest, TResponse> inner;
private readonly IAsyncPreRequestHandler<TRequest>[] preRequestHandlers;
private readonly IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers;
public AsyncMediatorPipeline(IAsyncRequestHandler<TRequest, TResponse> inner, IAsyncPreRequestHandler<TRequest>[] preRequestHandlers, IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers)
{
this.inner = inner;
@piers7
piers7 / LogInjectionModule
Last active January 6, 2016 03:01
Generic Autofac logging injector
using System;
using System.Linq;
using Autofac;
using Autofac.Core;
namespace Autofac.Logging
{
/// <summary>
/// Sets up automatic DI for service dependencies on <typeparamref name="TLogger"/>,
/// via an external factory that resolves based on the type of the resolver
@PurpleBooth
PurpleBooth / README-Template.md
Last active November 13, 2024 22:21
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@benaadams
benaadams / Streams-MixinsAndCombines.cs
Last active November 26, 2015 23:25
Stream Evolution in Interfaces (Mixins+Streams)
// Interface segregation (Combined Mixin+Non-mixin)
// For no-mixins version see https://gist.github.com/benaadams/d35ff5c534a43fd6c89d
// For mixins/generic constraints version see https://gist.github.com/benaadams/77c6e7aa34aae92b876a
// Do something with sync Reading, Seeking, Disposable stream (Generic Constraints)
public static void DoSomething<T>(T stream) where T : IBlockingReader, ISeekable, ISizable, IDisposable
{
stream.ReadByte();
stream.SetLength(6);
stream.Position = 5;