Skip to content

Instantly share code, notes, and snippets.

View danbarratt's full-sized avatar

Dan Barratt danbarratt

View GitHub Profile
@danbarratt
danbarratt / git-gc-all.ps1
Created February 1, 2017 09:21
Run 'git gc' in each subdirectory
$originalWorkingDir = Get-Location;
$subDirectories = dir -Directory;
Foreach ($subDirectory in $subDirectories)
{
$projectDir = Join-Path $originalWorkingDir $subDirectory;
$gitDir = Join-Path $projectDir '.git'
if (Test-Path $gitDir -PathType Container)
{
@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);