Skip to content

Instantly share code, notes, and snippets.

View kevinswiber's full-sized avatar
🍄
lizard person

Kevin Swiber kevinswiber

🍄
lizard person
View GitHub Profile
@kevinswiber
kevinswiber / EnvironmentOutput.cs
Created January 5, 2011 01:00
Shows an example of NRack middleware...
using System;
using System.Collections.Generic;
using System.Linq;
using NRack.Adapters;
namespace NRack.Example.AspNet
{
public class EnvironmentOutput : ICallable, IIterable
{
private readonly dynamic _application;
@kevinswiber
kevinswiber / TabascoExample.cs
Created January 31, 2011 14:24
An example of a Tabasco resource.
using System.Collections.Generic;
using NRack.Helpers;
namespace Tabasco.Example
{
[Resource("/")]
public class Main
{
const string HtmlSkeleton = @"<html>
<head><title>Super Tabasco Example</title></head>
@kevinswiber
kevinswiber / Program.cs
Created March 20, 2011 05:54
Example of sharing stack traces between threads.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
namespace StackTraceSharing
{
public class Program
using NRack.Helpers;
namespace Tabasco.Example.AspNet
{
public class App : TabascoBase
{
[Get]
public IView Index()
{
return new Spark();
using System;
using NRack.Auth;
using NRack.Configuration;
using NRack.Helpers;
namespace NRack.Example.AspNet
{
public class Config : ConfigBase
{
public override void Start()
@kevinswiber
kevinswiber / Config.cs
Created August 10, 2011 00:31
Easy config.js API for NRack.Mixups.JavaScript
public override void Start()
{
var context = IronJsBootstrap.Initialize();
WireUpJavaScriptConfigurationObject(context);
var source = GetSourceString();
context.Execute(@"(function () {
var config = new Config();
@kevinswiber
kevinswiber / BadChickenReview.cs
Created August 31, 2011 22:55
Example of Nullable type hurting innocent puppies.
public class FoodRating
{
public int? Score { get; set; } // YAY, let's make it Nullable! Is this even valid?
}
public class ChickenReview
{
private readonly FoodRating _rating;
public ChickenReview(FoodRating rating)
@kevinswiber
kevinswiber / Program.cs
Created November 23, 2011 23:05
Passing messages between Node.js and C#.
using System;
using System.Text;
namespace NodeIPC
{
class Program
{
static void Main(string[] args)
{
var input = Console.OpenStandardInput();
@kevinswiber
kevinswiber / streamy.js
Created May 24, 2012 18:43
Readable/Writable Stream in Node.js
var Stream = require('stream');
var util = require('util');
var Streamy = function() {
Stream.call(this);
this.readable = true;
this.writable = true;
};
util.inherits(Streamy, Stream);
@kevinswiber
kevinswiber / hal.json
Created July 7, 2012 14:56
JSON Siren vs. HAL Representations
{
"_links": {
"self": { "href": "/orders" },
"next": { "href": "/orders?page=2" },
"find": { "href": "/orders{?id}", "templated": true }
},
"_embedded": {
"orders": [{
"_links": {
"self": { "href": "/orders/123" },