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
View tga.hs
{-|
Haskell port of OCaml http://pastebin.com/a66MDZkP
-}
import qualified Data.ByteString.Lazy as B
import Data.Word8
type Point = (Double, Double)
type Rgb = (Double, Double, Double)
tga :: (Point -> Rgb) -> Int -> Int -> String -> IO ()
View RandomArt.hs
{-|
Haskell port of F# http://fssnip.net/si
-}
import Control.Applicative ((<$>), (<*>))
import System.Random (randomIO, randomRIO)
import qualified Data.ByteString.Lazy as B
import Data.Word8
data Expr =
VariableX
@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 / AssemblyInfo.fs
Created Jun 18, 2015
commandline20x-pre_assemblyinfo.fs
View AssemblyInfo.fs
(*
* Minimal AssemblyInfo.fs for automatic help screen generation in Command Line Parser Library 2.0.x-pre.
*)
module YourProject.AssemblyInfo
open System.Reflection
[<assembly: AssemblyCopyright("Copyright (c) 2015 Your Name Here")>]
do()
View uninstall-mono.sh
#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-*
for dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do
(cd ${dir};
@gsscoder
gsscoder / process_darwin-2.go
Created May 31, 2015
From github.com/gsscoder/goproc as in commit 998e482ecd.
View process_darwin-2.go
// 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 / process_darwin.go
Created May 29, 2015
From github.com/gsscoder/goproc as in commit 13a38b6100.
View process_darwin.go
// 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 / 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");
You can’t perform that action at this time.