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 / 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;
@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 / FuncHelper.cs
Created Jul 16, 2015
C# Partial application and Currying
View FuncHelper.cs
#region Partial application and Currying
static class FuncHelper
{
public static Func<T2, T3, T4, TResult> ApplyPartial<T1, T2, T3, T4, TResult>
(Func<T1, T2, T3, T4, TResult> function, T1 arg1)
{
return (b, c, d) => function(arg1, b, c, d);
}
public static Func<T2, T3, TResult> ApplyPartial<T1, T2, T3, TResult>
@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 / Option-Monad.cs
Last active Dec 16, 2015
C# implementation of F# option<'a> monad. (This is the one used in upcoming CommandLine 2.0, so I've used Haskell naming).
View Option-Monad.cs
internal enum MaybeType { Just, Nothing }
/// <summary>
/// C# implementation of F# 'T option. Based on the one found in http://goo.gl/jMwzg.
/// Here Haskell naming is used, to not create confusion with local option concept.
/// </summary>
internal abstract class Maybe<T>
{
private readonly MaybeType tag;
@gsscoder
gsscoder / DynamicComparer.cs
Created Mar 29, 2013
Invokes Enumerable::SequenceEqual generic extension method with reflection.
View DynamicComparer.cs
static class DynamicComparer
{
public static bool DynamicEquals<T>(this T value, T other)
{
if (object.Equals(value, default(T)))
{
throw new ArgumentNullException("value");
}
if (object.Equals(other, default(T)))
@gsscoder
gsscoder / Pairwise.cs
Last active Dec 15, 2015
IEnumerable<T>::Pairwise extension method for C# modeled like an overload of F# Seq.pairwise<'T> (http://msdn.microsoft.com/it-it/library/ee370361.aspx).
View Pairwise.cs
public static IEnumerable<TResult> Pairwise<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TSource, TResult> selector)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (selector == null)
{
throw new ArgumentNullException("selector");
@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;
You can’t perform that action at this time.