Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Giacomo Stelluti Scala gsscoder

💭
I may be slow to respond.
Block or report user

Report or block gsscoder

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gsscoder
gsscoder / cmdline_test.fs
Created Mar 3, 2013
Just a snippet of test wrote against an unreleased branch of CommandLine.
View cmdline_test.fs
open System
open System.Reflection
open CommandLine
open CommandLine.Text
[<assembly: AssemblyCopyright("Copyright (c) 2013 Giacomo Stelluti Scala playing with FSharp")>]
do()
type options() =
[<Option(HelpText = "Let your program talk a lot.")>]
View OwinHttpListenerWithNancyFx.cs
namespace OwinHttpListenerWithNancyFx
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Nancy;
using Owin.Listener;
@gsscoder
gsscoder / FireflyHostingNancy.cs
Created Feb 18, 2013
Firefly hosting NancyFx.
View FireflyHostingNancy.cs
/*
* 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;
View SimpleOwinApp_on_OwinHttpListener.cs
var listener = new OwinHttpListener(
new WebApp().PrintRequest,
new IPAddress(new byte[] { 0, 0, 0, 0 }), 8899);
listener.Start();
listener.ListenAsync().Wait();
Console.ReadKey();
@gsscoder
gsscoder / CSharp_Partial_Implementation.cs
Created Feb 14, 2013
C# wish list: Partial Implementation of Interfaces
View CSharp_Partial_Implementation.cs
/*
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 {
@gsscoder
gsscoder / ReadOnlyDictionary.cs
Last active Oct 19, 2016
Generic ReadOnlyDictionary implemented in C#, for .NET < Version 4.5.
View ReadOnlyDictionary.cs
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;
}
@gsscoder
gsscoder / HttpHelpersDemo1.cs
Last active May 16, 2017
Super-Simple HTTP Server, demonstrates use of https://github.com/gsscoder/httphelpers (work in progress).
View HttpHelpersDemo1.cs
/*
* 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
*/
@gsscoder
gsscoder / PeekableReader.cs
Last active Dec 13, 2015
Peekable stream reader for .NET/C#.
View PeekableReader.cs
// better than PeekableStream: less code, less bugs
sealed class PeekableReader : IDisposable
{
public PeekableReader(Stream stream)
{
_stream = stream;
_byte = _stream.ReadByte();
}
public int ReadByte()
@gsscoder
gsscoder / PeekableStream.cs
Last active Dec 13, 2015
Peekable readonly .NET/C# stream, implemented for https://github.com/gsscoder/httphelpers.
View PeekableStream.cs
// 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;
}
@gsscoder
gsscoder / SurfSample1.cs
Last active May 16, 2017
Super-Simple HTTP Server, demonstrates use of https://github.com/gsscoder/surfhttp (work in progress).
View SurfSample1.cs
/*
* 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;
You can’t perform that action at this time.