Skip to content

Instantly share code, notes, and snippets.

View davidfowl's full-sized avatar

David Fowler davidfowl

View GitHub Profile
@davidfowl
davidfowl / defaultwap.cmd
Created August 13, 2012 15:58
Default WAP kudu cmd
@echo off
:: Specify project file
IF "%PROJECT%" == "" (
SET PROJECT=PROJECTFILEGOESHERE
)
IF "%PROJECT%" == "PROJECTFILEGOESHERE" goto MissingProject
:: Specify project configuration
@davidfowl
davidfowl / today.cs
Created September 7, 2012 23:17
VNext SignalR API
Clients.addMessage(message);
Others.addMessage(message); // Does not exist yet
Clients[group].addMessage(message);
Clients[Context.ConnectionId].addMessage(message);
IClientProxy proxy = Clients;
proxy.Invoke("addMessage", message);
IClientProxy proxy1 = Clients[group];
proxy1.Invoke("addMessage", message);
@davidfowl
davidfowl / gist:3703926
Created September 12, 2012 02:47
Performance Showdown
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
@davidfowl
davidfowl / gist:3950340
Created October 25, 2012 03:57
Expression Redux
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
@davidfowl
davidfowl / gist:3950404
Created October 25, 2012 04:25
Initialize new service bus API manually within ROLES
private static int GetRoleInstanceNumber()
{
var roleInstanceId = RoleEnvironment.CurrentRoleInstance.Id;
var li1 = roleInstanceId.LastIndexOf(".");
var li2 = roleInstanceId.LastIndexOf("_");
var roleInstanceNo = roleInstanceId.Substring(Math.Max(li1, li2) + 1);
return Int32.Parse(roleInstanceNo);
}
string connectionString = // Your connection string
@davidfowl
davidfowl / gist:4015810
Created November 5, 2012 07:33
Detect ASP.NET shutdown
internal class ShutdownDetector : IRegisteredObject, IDisposable
{
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
private Timer _checkAppPoolTimer;
private static readonly TimeSpan _appPoolCheckInterval = TimeSpan.FromSeconds(10);
public CancellationToken Token
{
get { return _cts.Token; }
}
@davidfowl
davidfowl / AllMethods.cs
Created November 12, 2012 02:14
Blog Post
public class Chat : Hub
{
public void Send(string message)
{
// Call send on everyone
Clients.All.send(message);
// Call send on everyone except the caller
Clients.Others.send(message);
@davidfowl
davidfowl / Async.cs
Created December 5, 2012 18:16
Async for fun
static IEnumerable<Task> DoItAsync()
{
yield return Task.Delay(1000);
yield return Task.Run(() => 1 + 1);
Console.WriteLine("hello");
}
public static Task AsyncEnumerator(Func<IEnumerable<Task>> taskChainFactory)
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
5000 connections:
73d237c4 5000 60000 System.Threading.CancellationToken
05ae8b40 5000 60000 Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass5`1[[System.Threading.Tasks.Task, mscorlib]]
05a522cc 5000 60000 Microsoft.AspNet.SignalR.Infrastructure.SafeSet`1[[System.String, mscorlib]]
05a51624 5000 60000 Microsoft.AspNet.SignalR.Connection+<>c__DisplayClass2
01434310 5000 60000 System.Threading.Tasks.TaskCompletionSource`1[[Microsoft.AspNet.SignalR.Client.Http.IResponse, Microsoft.AspNet.SignalR.Client]]
05ae8dd8 5429 65148 Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass9`1[[System.Threading.Tasks.Task, mscorlib]]
05aecf48 5000 80000 Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass1c
05aece24 5000 80000 Microsoft.AspNet.SignalR.Infrastructure.CancellationTokenExtensions+<>c__DisplayClass4`1[[System.IDisposable, mscorlib]]