Skip to content

Instantly share code, notes, and snippets.

View serialseb's full-sized avatar

Sebastien Lambla serialseb

View GitHub Profile
@serialseb
serialseb / test
Last active December 25, 2015 20:59
Tests for calculator
1+1,2
1.1+0.1,1.2
1+-1,0
-2+1,-1
1+2+3,6
2*3,6
2*-3,-6
2*3*4,24
3+3*4,15
(3+3)*4,24
@serialseb
serialseb / gist:1373311
Created November 17, 2011 14:52
rest-aurant client
class Program
{
private const string REL_RESTAURANT_LIST = "http://rest.aurant.org/restaurant-list";
static void Main(string[] args)
{
var restaurantHref = DiscoverRestaurantListUri();
Console.WriteLine("Using " + restaurantHref);
var selectedRestaurant = SelectRestaurantUri(restaurantHref);
public static IEnumerable<Dictionary<string, string>> ItemScope(this XDocument document, string schema, params string[] propertyNames)
{
return from node in document.Document.Descendants()
where node.HAttr("itemtype") == schema
where node.HAttr("itemscope") == "itemscope"
select (from property in node.Descendants()
let propName = property.HAttr("itemprop")
where propertyNames.Contains(propName)
select property).ToDictionary(_=>_.HAttr("itemprop"), _=>_.Value);
}
@serialseb
serialseb / gist:1373164
Created November 17, 2011 13:45
Parsing link headers quick and dirty
static internal class ResponseExtensions
{
public static string GetLinkValue(this WebResponse response, string rel)
{
return (from header in response.Headers["Link"].Split(',')
let components = header.Split(';')
let uri = components[0]
where components.Any(
component =>
Regex.IsMatch(component,
@serialseb
serialseb / gist:1238163
Created September 23, 2011 18:59
Which language do you prefer?
ResourceSpace.Has.Resource<Home>()
/*(1)*/ .Map(_=>_.LastModified(r=>r.UpdateTime)
.Etag(r=>r.ID))
/*(2)*/ .MapLastModified(_=>_.UpdateTime)
.MapEtag(r=>r.ID)
/*(3)*/ .Map().LastModified(_=>_.UpdateTime)
.Etag(_=>_.ID)
@serialseb
serialseb / ddd-excercise1
Created December 8, 2010 14:56
A simple value object in .net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace DDD_1
{
class Program
{