Skip to content

Instantly share code, notes, and snippets.

@PeteGoo
PeteGoo / Global.asax.cs
Created April 9, 2012 00:24
ProtobufNetFormatter for Web API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@PeteGoo
PeteGoo / Global.asax.cs
Created August 19, 2012 04:30
An implementation of a SignalR Persistent Connection in Pushqa that understands OData filters (no IObservable etc needed just filtering normal SignalR event streams)
public class Global : System.Web.HttpApplication {
protected void Application_Start(object sender, EventArgs e) {
// Register the SignalR route for our event context at /events
RouteTable.Routes.MapConnection<SampleUsageConnection>("chat", "chat/{*operation}");
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
using CacheCow.Client.FileCacheStore;
namespace Caching.WpfApp {
public class PeopleProxy {
public async Task<IEnumerable<Person>> GetAll() {
var handler = new CachingHandler(
@PeteGoo
PeteGoo / ObservableTest.cs
Created January 21, 2013 19:58
Demonstrates using Rx to turn an incoming event stream into a grouped set of event streams based on the content. This time we use Throttle to have those groups clean themselves up (Complete) when there is a period of inactivity. Renewed activity on a cleaned up group will create a new group.
using System;
using System.Linq;
using System.Reactive.Linq;
namespace RxGroupByUntil {
class Program {
static void Main(string[] args) {
PrintSequences();
Console.ReadLine();
}
@PeteGoo
PeteGoo / Output
Last active December 14, 2015 06:39
a:
b:
setting a = a1
a: a1
b:
setting b = b1
a: a1
b: b1
setting a = b1
a: a2
@PeteGoo
PeteGoo / math.cs
Created October 12, 2013 23:35
mmbot scriptcs example
var robot = Require<Robot>();
robot.Respond(@"(calc|calculate|calculator|convert|math|maths)( me)? (.*)", msg =>
{
msg
.Http("https://www.google.com/ig/calculator")
.Query(new
{
hl = "en",
q = msg.Match[3]
@PeteGoo
PeteGoo / math.cs
Created October 12, 2013 23:38
An IMMBot math script implemented using IMMBotScript
public class Math : IMMBotScript
{
public void Register(Robot robot)
{
robot.Respond(@"(calc|calculate|calculator|convert|math|maths)( me)? (.*)", async msg =>
{
dynamic res = await msg
.Http("https://www.google.com/ig/calculator")
.Query(new
{
@PeteGoo
PeteGoo / startingmmbot.cs
Last active December 25, 2015 09:39
Starting mmbot
static void Main(string[] args)
{
var config = new Dictionary<string, string>
{
{"MMBOT_JABBR_HOST", "https://jabbr.net/"},
{"MMBOT_JABBR_NICK", "mmbot"},
{"MMBOT_JABBR_PASSWORD", "mypassword"},
{"MMBOT_JABBR_ROOMS", "mmbottestroom"},
};
}
@PeteGoo
PeteGoo / 01. Website support chat
Last active January 1, 2016 03:59
Xbox One support nightmares
11/11/2013
Basically I told them I was double billed when I ordered Xbox live gold via the console.
They
* Re-imbursed me one of the payments
* Cancelled my gold subscription
* Gave me a code - see 2.
var robot = Require<Robot>();
robot.Respond("updog", msg => msg.Send("What's up dog?"));