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 / cmdline-snippet-1.cs
Last active December 11, 2015 15:48
Command Line Parser, option declaration pre-1.9.4.91 beta.
[Option("q", "quiet", HelpText = "Suppress summary message.")]
public bool Quiet { get; set; }
@gsscoder
gsscoder / cmdline-snippet-2.cs
Last active December 11, 2015 15:59
Command Line Parser, option declaration post-1.9.4.91 beta.
[Option('q', "quiet", HelpText = "Suppress summary message.")]
public bool Quiet { get; set; }
@gsscoder
gsscoder / cmdline-snippet-3.cs
Created January 24, 2013 16:57
Command Line Parser, verbs sub options.
class CommitSubOptions
{
[Option('p', "patch",
HelpText = "Use the interactive patch selection interface to chose which changes to commit.")]
public bool Patch { get; set; }
[Option('a', "all",
HelpText = "Tell the command to automatically stage files that have been modified.")]
public bool All { get; set; }
}
@gsscoder
gsscoder / cmdline-snippet-4.cs
Created January 24, 2013 17:00
Command Line Parser, verbs master options.
class Options
{
public OptionsWithVerbsHelp()
{
CommitVerb = new CommitSubOptionsHelp {Patch = true};
}
[VerbOption("add", HelpText = "Add file contents to the index.")]
public AddSubOptions AddVerb { get; set; }
@gsscoder
gsscoder / cmdline-snippet-5.cs
Created January 24, 2013 17:02
Command Line Parser, verbs GetUsage.
class Options : CommandLineOptionsBase
{
// option attributes as above...
[HelpVerbOption]
public string GetUsage(string verb)
{
bool found;
var instance = (CommandLineOptionsBase) CommandLineParser.GetVerbOptionsInstanceByName(verb, this, out found);
var verbsIndex = verb == null || !found;
var target = verbsIndex ? this : instance;
@gsscoder
gsscoder / easycalc.opa
Created January 24, 2013 17:12
Simple MLState Opa Calculator.
function sum()
{
a = Int.of_string(Dom.get_value(#vala));
b = Int.of_string(Dom.get_value(#valb));
#res = a + b;
}
function start() {
<div>EasyCalc</div>
<div>
@gsscoder
gsscoder / opa-calc-snippet-1.opa
Created January 24, 2013 17:15
Opa Calculator, Snippet 1.
a = Int.of_string(Dom.get_value(#vala));
@gsscoder
gsscoder / opa-calc-snippet-2.opa
Created January 24, 2013 17:16
Opa Calculator, Snippet 2.
#res = a + b;
@gsscoder
gsscoder / closure-conf.cs
Last active November 7, 2019 14:17
Illustrates how to configure an object using closures in C#
class Program
{
static void Main(string[] args)
{
var obj1 = new ToBeConfigured(with =>
{
with.UseB();
with.SetParam("something");
});
@gsscoder
gsscoder / RenameFixtureMethods.fs
Last active November 7, 2019 14:17
Simple F# program to rename my C# test fixture methods
(*
Description: Simple program to change naming conventions of my C# test fixtures.
Purpose: Learn F#!
Author: Giacomo Stelluti Scala
Created: 2013-01-28
*)
open System
open System.IO
open System.Globalization
open System.Text