Skip to content

Instantly share code, notes, and snippets.

public class Chat : Hub
{
public void LoadPlotData()
{
ThreadPool.QueueUserWorkItem(x => {
var firstPlotData = Db.LoadFirstPlotData();
Clients.Caller.firstPlotDataRetrieved(firstPlotData);
});
ThreadPool.QueueUserWorkItem(x => {
function MessageBus() {
var self = this;
var subscribable = new ko.subscribable();
self.publish = function (bus, message) {
subscribable.notifySubscribers(message, bus);
};
self.subscribe = function (bus, callback, callbackTarget) {
subscribable.subscribe(function (message) {
callback(ko.toJS(message));
}, callbackTarget || this, bus);
using System;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using FamilyClub.Data.Mappers;
using FamilyClub.Model;
using TecUnica.Core.Data.NPoco;
namespace FamilyClub
@luisrudge
luisrudge / BrowserInfo.cs
Last active December 16, 2015 11:38
Some thoughts around server side browser detection
public class BrowserInfo
{
private readonly HttpContextBase _context;
public BrowserInfo(HttpContextBase context)
{
_context = context;
}
public HttpBrowserCapabilitiesBase HttpBrowserCapabilities
@luisrudge
luisrudge / classes.cs
Last active December 18, 2015 12:59
scriptcs idea
//Just for the sake of constraint
public interface INakeTaskConfiguration { }
//NakeTask base class
public abstract class NakeTask
{
protected readonly IDictionary<string, Action> Do = new Dictionary<string, Action>();
public virtual void Initialize()
{
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/*
* Arduino.cs - Arduino/firmata library for Visual C# .NET
* Copyright (C) 2009 Tim Farley
*
* Special thanks to David A. Mellis, on whose Processing library
* this code is based.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@luisrudge
luisrudge / async c#.cs
Created April 23, 2014 19:43
async console app
using System.Threading.Tasks;
namespace ConsoleApplication1 {
internal class Program {
private static void Main(string[] args) {
RunAsync().Wait();
}
private static async Task RunAsync() {
//your async code
@luisrudge
luisrudge / auth.cs
Created April 25, 2014 21:33
stateless auth for nancy
public static class Authentication {
public const string Secret = "123@123";
public static void Setup(IPipelines pipelines, Db db) {
var c = new StatelessAuthenticationConfiguration(ctx => {
var username = ctx.Request.Headers[Constants.HeaderUsername].FirstOrDefault();
var hash = ctx.Request.Headers[Constants.HeaderHash].FirstOrDefault();
if (String.IsNullOrEmpty(username)) {
return null;
}
@luisrudge
luisrudge / DbTest.cs
Created May 8, 2014 13:54
testing entity framework C#
public abstract class DbTest {
protected MyDbContext Db;
private DbConnection _connection;
protected abstract DbConnection DbConnection { get; }
[SetUp]
public virtual void Setup() {
CreateContext(true);
Db.Database.CreateIfNotExists();
Db.Database.Initialize(true);