Skip to content

Instantly share code, notes, and snippets.

@Krummelz
Krummelz / Useful C# Extension Methods
Created September 12, 2013 07:26
Useful C# Extension Methods
/// <summary>
/// This will return a camel-cased string, so that it reads as a normal string, by adding a space before each capital letter.
/// </summary>
public static string SpaceOutCamelCasing(this string theWord)
{
char[] temp = theWord.ToCharArray();
string Result = "";
foreach (char c in temp)
if (c.ToString() == c.ToString().ToUpper())
@Slesa
Slesa / gist:5899421
Created July 1, 2013 09:02
A FAKE target for a click once application
#I @"Tools\Fake"
#r "FakeLib.dll"
open Fake
let buildNumber =
if hasBuildParam "version" then getBuildParam "version" else
if isLocalBuild then "0" else
buildVersion
let version =
@danbarratt
danbarratt / gist:2243414
Created March 29, 2012 20:28
Download all GL Journals from XeroAPI.dll wrapper library
// Get GL Journals using the ?offset=xxx parameter
List<Journal> allJournals = new List<Journal>();
List<Journal> batchOfJournals;
int skip = 0;
while ((batchOfJournals = repository.Journals.Skip(skip).ToList()).Count > 0)
{
Console.WriteLine("Fetched {0} journals from API using skip={1}", batchOfJournals.Count, skip);
allJournals.AddRange(batchOfJournals);
@danbarratt
danbarratt / gist:1068916
Created July 7, 2011 05:07
Get a contact from Xero API using the ContactNumber field
var querystrings = new System.Collections.Generic.Dictionary<string, string>();
querystrings.Add("where", "ContactNumber = \"123\"");
querystrings.Add("order", "Name DESC");
IConsumerRequest filteredGetContactRequest = consumerSession
.Request()
.ForMethod("GET")
.WithQueryParameters((IDictionary)querystrings)
.ForUri(new Uri("https://api.xero.com/api.xro/2.0/Contacts"))
.SignWithToken(accessToken);