This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' needs CommandLine.dll prior to 1.9.4.91 | |
' for later versions: templates are up to date | |
Imports CommandLine | |
Imports CommandLine.Text | |
Imports System.Reflection | |
<Assembly: [AssemblyInformationalVersion]("1.0.0.0")> | |
Friend Class ThisAssembly | |
Friend Shared Title As String = "VBNetTemplate" | |
Friend Shared Author As String = "Your Name Here" | |
Friend Shared Copyright As String = "Copyright (C) 2012 " + Author |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Text; | |
using System.ComponentModel.Composition; | |
using System.Threading.Tasks; | |
using AppFunc = System.Func< // Call | |
System.Collections.Generic.IDictionary<string, object>, // Environment | |
System.Threading.Tasks.Task>; // Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Toy HTTP Sample Server | |
* Giacomo Stelluti Scala (gsscoder@gmail.com) | |
* Demonstrates use of https://github.com/gsscoder/surfhttp (work in progress). | |
* How to execute: Copy & paste, then add a reference to Surf.dll. | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Globalization; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PeekableReader is better -> https://gist.github.com/gsscoder/4945440 | |
sealed class PeekableStream : Stream | |
{ | |
public PeekableStream(Stream stream) | |
{ | |
_stream = stream; | |
_peeked = new byte[16]; | |
_peekedLength = 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// better than PeekableStream: less code, less bugs | |
sealed class PeekableReader : IDisposable | |
{ | |
public PeekableReader(Stream stream) | |
{ | |
_stream = stream; | |
_byte = _stream.ReadByte(); | |
} | |
public int ReadByte() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Easy HTTP Sample Server | |
* Version 0.0.0.6 (based on HttpHelpers 0.1.5.0-alfa) | |
* Giacomo Stelluti Scala (gsscoder@gmail.com) | |
* Demonstrates use of https://github.com/gsscoder/httphelpers (work in progress) | |
* How to execute: Copy & paste, then add a reference to HttpHelpers.dll | |
* It handles two url: | |
* (1) http://localhost:8899/hello -> point browser & refresh | |
* (2) everything helse | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue> | |
{ | |
internal class KeyCollection : ICollection<TKey> | |
{ | |
public KeyCollection(ICollection<TKey> collection) | |
{ | |
if (collection == null) { throw new ArgumentNullException("collection"); } | |
_collection = collection; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
for C# wish list | |
---------------- | |
partial implementation of interface while coding | |
(something can be done with DynamicMethod, IL generation | |
but I'd like a language feature) | |
*/ | |
interface IMyInterface { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var listener = new OwinHttpListener( | |
new WebApp().PrintRequest, | |
new IPAddress(new byte[] { 0, 0, 0, 0 }), 8899); | |
listener.Start(); | |
listener.ListenAsync().Wait(); | |
Console.ReadKey(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Install-Package Firefly | |
* Install-Package Nancy | |
* Install-Package Nancy.Owin (or just this, will pull the former) | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Firefly.Http; |