Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View DamianEdwards's full-sized avatar
🏠
Working from home

Damian Edwards DamianEdwards

🏠
Working from home
View GitHub Profile
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using SignalR.Infrastructure;
namespace SignalR
@DamianEdwards
DamianEdwards / gist:1654095
Created January 21, 2012 21:29
Moar Signalr
using System;
using System.Collections.Generic;
using System.Threading;
namespace SignalR.Infrastructure
{
internal class LockedList<T> : List<T>
{
private readonly ReaderWriterLockSlim _listLock = new ReaderWriterLockSlim();
@DamianEdwards
DamianEdwards / gist:1734345
Created February 4, 2012 01:41
Crazy TPL helper from SignalR for the day
public static Task Interleave<T>(Func<T, Action, Task> before, Func<Task> after, T arg)
{
var tcs = new TaskCompletionSource<object>();
var tasks = new[] {
tcs.Task,
before(arg, () => after().ContinueWith(tcs))
};
return tasks.Return();
}
@DamianEdwards
DamianEdwards / gist:3758904
Created September 20, 2012 23:14
SignalR + Knockout Chat
<form data-bind="submit: sendMessage">
<input type="text" data-bind="value: newMessage" />
<input type="submit" value="Send" />
</form>
<ul data-bind="foreach: messages">
<li data-bind="text: $data"></li>
</ul>
<script src="Scripts/jquery-1.8.1.js"></script>
@DamianEdwards
DamianEdwards / gist:4030394
Created November 7, 2012 09:31
Async site scraping in ASP.NET 4.5
public class SiteScrape : HttpTaskAsyncHandler
{
public override async Task ProcessRequestAsync(HttpContext context)
{
using (var http = new HttpClient())
{
var downloadTasks = new List<Task<string>> {
http.GetStringAsync("http://bing.com"),
http.GetStringAsync("http://google.com"),
http.GetStringAsync("http://oredev.org"),
@DamianEdwards
DamianEdwards / gist:4032153
Created November 7, 2012 15:09
Model binding to a dynamic object using an anon type as the "shape"
public partial class AdHocModelBindingAnonType : System.Web.UI.Page
{
protected dynamic Model { get; private set; }
protected void Page_Load()
{
Model = ModelBindingExecutionContext.Bind(new { FirstName = "" });
}
}
@DamianEdwards
DamianEdwards / gist:4032179
Created November 7, 2012 15:14
Some Model Binding helpers for ASP.NET Web Forms 4.5
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.ModelBinding;
namespace VS11BetaTAPWebForms
@DamianEdwards
DamianEdwards / gist:4499713
Created January 10, 2013 05:37
SignalR chat using Knockout sync models idea
<form data-bind="submit: sendMessage">
<input type="text" data-bind="value: newMessage" />
<input type="submit" value="Send" />
</form>
<ul data-bind="foreach: messages">
<li data-bind="text: $data"></li>
</ul>
<script src="Scripts/jquery-1.8.3.js"></script>
@DamianEdwards
DamianEdwards / ChatHub.cs
Created January 10, 2013 06:10
SignalR peer-to-peer using class-less hubs idea
// This hub is optional, it's not required for the client to work.
// The client's call to "all.newMessage" will result in this Hub's
// NewMessage method being called so it can persist the message.
public class Chat : Hub
{
public void NewMessage(string message)
{
MyDataLayer.SaveMessage(message);
}
}
@DamianEdwards
DamianEdwards / gist:4958622
Created February 15, 2013 04:45
My Windows Phone 8 apps
4th & Mayor - FourSqaure client
Add to Calendar - support for ICS files attached to emails
Amazon Kindle
Amazon Mobile - can't live without this as a Seattelite
AppoinTile - more detailed upcoming appointments/meetings tile
Baconit - reddit client
Battery Level for WP8 - let's you see detailed battery status from lock screen, home screen, etc.
CrashPlan - so I can check my cloud backups
Dictionary.com - to settle arguments
Engadget - tech news