Skip to content

Instantly share code, notes, and snippets.

View tugberkugurlu's full-sized avatar
:shipit:
💥 shakalaka

Tugberk Ugurlu tugberkugurlu

:shipit:
💥 shakalaka
View GitHub Profile
@tugberkugurlu
tugberkugurlu / gist:3848723
Created October 7, 2012 15:50 — forked from benfoster/gist:3848715
Adding IServiceProvider to ValidationContext in ASP.NET MVC
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
/* usual sh** ommitted for brevity */
var resolver = new CustomDependencyResolver();
DependencyResolver.SetResolver(resolver);
DataAnnotationsModelValidatorProvider.RegisterDefaultAdapterFactory(
@tugberkugurlu
tugberkugurlu / gist:3949100
Created October 24, 2012 21:43 — forked from pmhsfelix/gist:3949044
Canonicalized Header and Resource String
private static string[] GetCanonicalizedHeaders(HttpRequestHeaders headers)
{
return headers
.Where(p => p.Key.StartsWith("x-ms-", StringComparison.InvariantCultureIgnoreCase))
.Select(p => new { Name = p.Key.ToLower(), Value = p.Value.First() })
.OrderBy(p => p.Name)
.Select(p => string.Format("{0}:{1}", p.Name, p.Value))
.ToArray();
}
@tugberkugurlu
tugberkugurlu / gist:3587448
Created September 1, 2012 21:10 — forked from benfoster/gist:3555524
AtomPubMediaTypeFormatter for ASP.NET Web API
public class AtomPubMediaFormatter : MediaTypeFormatter
{
private const string Atom = "application/atom+xml";
public AtomPubMediaFormatter()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue(Atom));
this.AddQueryStringMapping("format", "atom", Atom);
}
@tugberkugurlu
tugberkugurlu / gist:3852195
Created October 8, 2012 12:11 — forked from benfoster/gist:3848727
A custom DataAnnotationsModelValidatorProvider that injects IServiceProvider into ValidationContext
public class CustomDataAnnotationsModelValidatorProvider : DataAnnotationsModelValidatorProvider
{
private readonly IServiceProvider serviceProvider;
public CustomDataAnnotationsModelValidatorProvider(IServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider;
DataAnnotationsModelValidatorProvider.RegisterDefaultAdapterFactory(
(metadata, context, attribute) =>
public class Configuration(IAppBuilder app)
{
// TaskCompletionSource
app.Map("/streaming-api1", map =>
{
// Streaming API using SignalR
var connectionContext = GlobalHost.ConnectionManager.GetConnectionContext<RawConnection>();
map.Run(async context =>
{
internal sealed class Configuration : DbMigrationsConfiguration<SpatialDemo.Models.SpatialDemoContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(SpatialDemo.Models.SpatialDemoContext context)
{
context.Locations.AddOrUpdate((x) => x.Name,
Set-ExecutionPolicy RemoteSigned
$mongoDbPath = "C:\MongoDB"
$mongoDbConfigPath = "$mongoDbPath\mongod.cfg"
$url = "http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.2.3.zip"
$zipFile = "$mongoDbPath\mongo.zip"
$unzippedFolderContent ="$mongoDbPath\mongodb-win32-x86_64-2008plus-2.2.3"
if ((Test-Path -path $mongoDbPath) -eq $True)
{
<appSettings>
<add key="aspnet:UseHostHeaderForRequestUrl" value="true"/>
</appSettings>
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
[Test]
public void Should_be_able_to_consume()
{
var autoResetEvent = new AutoResetEvent(false);
using (var channel = connection.OpenChannel())
{
channel.Declare(queue);
var settings = new ConsumerSettings(queue)