Skip to content

Instantly share code, notes, and snippets.

View tucaz's full-sized avatar

tucaz tucaz

View GitHub Profile
reservaExistente = new ReservaBuilder()
.ComProduto(produtoReservado, 1)
.ParaCliente(null)
.ComOrigem(OrigemVenda.Parceiro)
.VigentePor(3)
.Build();
SIF Utiltiy
SIF Upload
SIF parsing
Authentication
Authentication User
Authentication User for posting
Authentication Customer # for the user setup
Authentication Customer # from the file
XML Processing
XML translation/Parsing
@tucaz
tucaz / NUnitDataTest.cs
Created December 8, 2010 12:36
Generates one test method for each entry of external data using NUnit test framework
using NUnit.Framework;
namespace NUnitDataDriven
{
[TestFixture]
public class DataTests
{
[Test, TestCaseSource("GetDataForTesting")]
public void age_should_be_over_18(Data data)
{
@tucaz
tucaz / gist:748462
Created December 20, 2010 14:59
StateMonad in F#
#light
namespace NParser
module StateMonad =
type State<'s,'a> = State of ('s -> ('a *'s))
let runState (State f) = f
type StateBuilder() =
member b.Return(x) = State (fun s -> (x,s))
member b.Delay(f) = f() : State<'s,'a>
#light
namespace NParser
module Lexer =
open System
open System.Collections.Generic
open System.Text.RegularExpressions
open StateMonad
#light
namespace NParser
open System
open Lexer
type NomosParser() =
static member Parse(stringToParse:string) =
let definitions = state {
do! addDefinition "String" "[a-zA-Z]+"
let entryDate = match List.filter dateToken tokens with
| r when r.Length > 0 ->
Some(Seq.head r)
| otherwise ->
None
@tucaz
tucaz / gist:757678
Created December 28, 2010 20:36
Comparativo C# v.s. F#
//C#
public T FindInList(List<T> source, List<T> target>
{
foreach(T item in source)
{
foreach(T targ in target)
{
if(item == targ)
return item
public class ProductDetailTranslator
{
public ProductDetail Translate(string xmlFrom)
{
var productTo = new ProductDetail();
var xmlReader = XmlReader.Create(new StringReader(xmlFrom));
var productDetail = XElement.Load(xmlReader);
var parentGroups = productDetail.Elements("Grouping").First().Elements("section")
.Select(parentGroup => new Group() { Name = parentGroup.Elements("displayname").First().Value, Items = GetChildren(parentGroup).ToList() });
@tucaz
tucaz / LinkedList.js
Created July 5, 2011 00:03
Simple double linked list in javascript
var Node = function (v) {
if ( !(this instanceof arguments.callee) ) {
throw new Error("Constructor called as a function");
}
this.value = v;
this.next = null;
this.previous = null;
}