Skip to content

Instantly share code, notes, and snippets.

View simoneb's full-sized avatar

Simone Busoli simoneb

View GitHub Profile
@simoneb
simoneb / README.md
Last active August 29, 2015 13:56
MyWind.it dashing widget

Description

Dashing widget to show details about your Italian Wind mobile contracts. It supports both prepaid SIM cards and contracts and can display:

  • credit
  • voice traffic
  • text traffic
  • data traffic
  • expiries
DQuid IO - OAuth2 - Implementation
===================
This document contains a guide to implement an OAuth2 client for DQuid IO's services.
## A brief overview of OAuth2
### Access Tokens
APIs protected via OAuth2 require what is known as an **access token** to be accessed. An access token allows to implement a form of HTTP authentication which requires the token to be sent **alongside every request**, most commonly in the **authorization** header of the HTTP request:
@simoneb
simoneb / 1 - Test.cs
Last active September 3, 2015 21:44
KataPotter
[TestFixture]
public class Test : Calculator
{
[Test]
public void No_books_are_0()
{
Assert.AreEqual(0, Price());
}
[Test]
public static class Extensions
{
public static bool And(this IEnumerable<bool> bools)
{
return bools.Foldr(Expression.AndAlso, true);
}
public static T Foldr<T>(this IEnumerable<T> enumerable, Func<Expression, Expression, BinaryExpression> fold, T v)
{
foreach(var b in enumerable)
@simoneb
simoneb / costura.xml
Created November 21, 2011 15:57
Costura task
<UsingTask
TaskName="Costura.EmbedTask"
AssemblyFile="$(SolutionDir)[path to]\Costura.dll" />
<Target Name="AfterBuild">
<Costura.EmbedTask />
</Target>
@simoneb
simoneb / gist:1562857
Created January 4, 2012 23:36
Anagrams
IEnumerable<string> Anagrams(IEnumerable<char> input)
{
foreach (var c in input)
{
var except = input.Except(new[]{c});
if(except.Any())
foreach (var element in Anagrams(except))
yield return c.ToString() + element;
else
@simoneb
simoneb / gist:2508758
Created April 27, 2012 12:20
Async IO the simple way
using(var c = new WebClient())
{
c.DownloadStringCompleted += (_, r) => Console.WriteLine(r.Result);
c.DownloadStringAsync(new Uri("http://www.google.at"));
}
@simoneb
simoneb / nunit-simple-test.cs
Last active December 11, 2015 08:48
A simple test
[Test]
public void OneSimpleTest()
{
var eightBall = new EightBall();
var answer = eightBall.ShouldIChangeJob();
Assert.That(answer, Is.True);
}
@simoneb
simoneb / nunit-simple-test-workaround.cs
Last active December 11, 2015 08:48
A simple test - workaround for async
[Test]
public void OneSimpleTest()
{
var eightBall = new EightBall();
Task<bool> answer = eightBall.ShouldIChangeJob();
answer.Wait();
Assert.That(answer.Result, Is.True);
}