Skip to content

Instantly share code, notes, and snippets.

View gsscoder's full-sized avatar
💭
obsessive coding disorder

coder (π³) gsscoder

💭
obsessive coding disorder
View GitHub Profile
@gsscoder
gsscoder / opa-calc-snippet-2.opa
Created January 24, 2013 17:16
Opa Calculator, Snippet 2.
#res = a + b;
@gsscoder
gsscoder / CSharp_Partial_Implementation.cs
Created February 14, 2013 19:22
C# wish list: Partial Implementation of Interfaces
/*
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 / Pairwise.cs
Last active December 15, 2015 04:19
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).
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 / FuncHelper.cs
Created July 16, 2015 16:23
C# Partial application and Currying
#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 / pyenv-install-python-380.log
Created November 2, 2019 05:39
Pyenv debug output installing python 3.8.0
+ [pyenv:22] enable -f /usr/local/bin/../libexec/pyenv-realpath.dylib realpath
+ [pyenv:29] '[' -z '' ']'
++ [pyenv:31] type -p greadlink readlink
++ [pyenv:31] head -1
+ [pyenv:31] READLINK=/usr/bin/readlink
+ [pyenv:32] '[' -n /usr/bin/readlink ']'
+ [pyenv:57] '[' -z /Users/giacomo/.pyenv ']'
+ [pyenv:60] PYENV_ROOT=/Users/giacomo/.pyenv
+ [pyenv:62] export PYENV_ROOT
+ [pyenv:65] '[' -z '' ']'
@gsscoder
gsscoder / names.json
Last active November 7, 2019 14:02
List of names in JSON format
[
"Liam",
"Noah",
"William",
"James",
"Logan",
"Benjamin",
"Mason",
"Elijah",
"Oliver",
@gsscoder
gsscoder / process_darwin.go
Last active November 7, 2019 14:10
From github.com/gsscoder/goproc as in commit 13a38b6100
// Copyright 2015 Giacomo Stelluti Scala. All rights reserved. See doc/License.md in the project root for license information.
package process
/*
#include <stdlib.h>
#include "libproc.h"
*/
import "C"
import "unsafe"
@gsscoder
gsscoder / DynamicComparer.cs
Last active November 7, 2019 14:11
Invokes Enumerable::SequenceEqual generic extension method with reflection
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 / cmdline_test.fs
Last active November 7, 2019 14:11
Just a snippet of test wrote against an unreleased branch of CommandLine
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.")>]
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;