Skip to content

Instantly share code, notes, and snippets.

View beyond-code-github's full-sized avatar

Pete Smith beyond-code-github

View GitHub Profile
@beyond-code-github
beyond-code-github / Program.cs
Last active December 21, 2015 04:48
West London Hack Night - Reworked Brainfuck interpreter in C#
namespace BrainFuckContinued
{
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
var p = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.";
@beyond-code-github
beyond-code-github / sample.cs
Last active December 23, 2015 12:39
Hello world nancy
public class SampleModule : Nancy.NancyModule
{
public SampleModule()
{
Get["/"] = _ => "Hello World!";
}
}
namespace WebApiModuleHelloWorld
{
public class HelloWorldModule : Superscribe.WebApi.Modules.SuperscribeModule
{
public HelloWorldModule()
{
this.Get["/"] = _ => "Hello World!";
}
}
}
using System.Web.Http;
namespace WebApiModuleHelloWorld
{
using Superscribe.WebApi;
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
@beyond-code-github
beyond-code-github / HelloWorldModule.cs
Created September 20, 2013 12:25
HelloWorldModule with parameter capture
namespace WebApiModuleHelloWorld
{
using Superscribe.Models;
public class HelloWorldModule : Superscribe.WebApi.Modules.SuperscribeModule
{
public HelloWorldModule()
{
this.Get["/"] = _ => "Hello World!";
@beyond-code-github
beyond-code-github / TimeDependantRoute.cs
Last active December 23, 2015 13:19
Time dependant insulting route behavior with Superscribe
namespace WebApiModuleHelloWorld
{
using System;
using Superscribe.Models;
public class HelloWorldModule : Superscribe.WebApi.Modules.SuperscribeModule
{
public HelloWorldModule()
{
@beyond-code-github
beyond-code-github / ModelBinding.cs
Last active December 23, 2015 13:28
Model binding and returning a custom status code
namespace WebApiModuleHelloWorld
{
using System.Net;
public class Product
{
public string Name { get; set; }
public double Price { get; set; }
}
@beyond-code-github
beyond-code-github / CreateResponse.cs
Created September 20, 2013 18:45
Post handler with create response
this.Post["Products"] = _ =>
{
var product = _.Bind<Product>();
// Save product
return _.Request.CreateResponse(
HttpStatusCode.Created,
new { Link = new { href = string.Format("http://api.localhost/products/{0}", product.Id) } });
};
private static void RegisterServices(IKernel kernel)
{
kernel.Bind<IProductsService>().To<ProductsService>();
GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
}
@beyond-code-github
beyond-code-github / Require.cs
Created September 20, 2013 19:08
Example of dependency injection using Require
this.Get["Products" / (ʃLong)"Id"] = _ =>
{
var service = _.Require<IProductsService>();
return service.Get(_.Parameters.Id);
};
this.Post["Products"] = _ =>
{
var service = _.Require<IProductsService>();
var product = _.Bind<Product>();