Skip to content

Instantly share code, notes, and snippets.

View davidfowl's full-sized avatar

David Fowler davidfowl

View GitHub Profile
public class Global : System.Web.HttpApplication {
protected void Application_Start(object sender, EventArgs e) {
var store = new SmartMessageStore();
DependencyResolver.Register(typeof(IMessageStore), () => store);
}
}
@davidfowl
davidfowl / gist:1302887
Created October 21, 2011 01:32
IIS + sh.exe = fail
<%@ Page Language="C#" Debug="true" %>
<%
var exePath = @"C:\Program Files (x86)\Git\bin\sh.exe";
var working = @"C:\Program Files (x86)\Git\bin";
var args = "-c ls";
var psi = new System.Diagnostics.ProcessStartInfo {
FileName = exePath,
WorkingDirectory = working,
@davidfowl
davidfowl / MyHub.cs
Created October 29, 2011 11:19
C# Hubs API
using System;
using System.Threading;
using System.Threading.Tasks;
using SignalR.Hubs;
namespace Server
{
public class MyHub : Hub
{
public void Foo()
@davidfowl
davidfowl / Main.cs
Created April 29, 2012 23:21
WebApiSignalR SelfHost
var config = new HttpSelfHostConfiguration("http://localhost:8081");
config.TransferMode = TransferMode.StreamedResponse;
config.Routes.MapConnection<MyConnection>("Echo", "echo/{*operation}");
config.Routes.MapConnection<Raw>("Raw", "raw/{*operation}");
var dispatcher = new PersistentConnectionDispatcher(config);
var server = new HttpSelfHostServer(config, dispatcher);
server.OpenAsync().Wait();
@davidfowl
davidfowl / gist:2723952
Created May 18, 2012 08:26
AjaxMinFail
/*!
* SignalR JavaScript Library v0.5
* http://signalr.net/
*
* Copyright David Fowler and Damian Edwards 2012
* Licensed under the MIT.
* https://github.com/SignalR/SignalR/blob/master/LICENSE.md
*/
/// <reference path="jquery-1.6.2.js" />
@davidfowl
davidfowl / AsyncResult.cs
Created May 24, 2012 01:20
Before SignalR
// From http://msdn.microsoft.com/en-us/magazine/cc163467.aspx
internal class AsyncResult : IAsyncResult
{
// Fields set at construction which never change while
// operation is pending
readonly AsyncCallback m_AsyncCallback;
readonly Object m_AsyncState;
// Fields set at construction which do change after
// operation completes
@davidfowl
davidfowl / gist:2925621
Created June 13, 2012 18:18
Connection initialization in multiple pages
// --- outside of the user controls, e.g. on the container page ---
$(function() {
window.hubReady = $.connection.hub.start();
});
// --- in your other pages ---
$(function() {
window.hubReady.done(function() {
// call hub method
});
@davidfowl
davidfowl / gist:3155602
Created July 21, 2012 11:50
Fix ravendb SignalR
diff --git a/Imports/SignalR/SignalR.Client/Http/DefaultHttpClient.cs b/Imports/SignalR/SignalR.Client/Http/DefaultHttpClient.cs
index 345a30f..3999ed6 100644
--- a/Imports/SignalR/SignalR.Client/Http/DefaultHttpClient.cs
+++ b/Imports/SignalR/SignalR.Client/Http/DefaultHttpClient.cs
@@ -17,8 +17,12 @@ public class DefaultHttpClient : IHttpClient
/// <returns>A <see cref="Task{IResponse}"/>.</returns>
public Task<IResponse> GetAsync(string url, Action<IRequest> prepareRequest)
{
- return HttpHelper.GetAsync(url, request => prepareRequest(new HttpWebRequestWrapper(request)))
- .Then(response => (IResponse)new HttpWebResponseWrapper(response));
@davidfowl
davidfowl / gist:3172990
Created July 24, 2012 22:06
MethodInfo.Invoke is slow...
using System;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
@davidfowl
davidfowl / gist:3173128
Created July 24, 2012 22:36 — forked from jmangelo/gist:3173109
MethodInfo.Invoke is slow... open instance delegate to the rescue
using System;
using System.Linq;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program