Skip to content

Instantly share code, notes, and snippets.

View sawilde's full-sized avatar

Shaun Wilde sawilde

View GitHub Profile
using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using MYOB.AccountRight.SDK;
using MYOB.AccountRight.SDK.Communication;
using MYOB.AccountRight.SDK.Services;
namespace arl_winforms_sample
{
public partial class Form1 : Form
@sawilde
sawilde / enumerables_to_blocks.cs
Last active March 2, 2019 04:44
Break an array into blocks
var blockSize = 2;
var blocks = arrayListEnumerableOfThing
.Select((element, idx) => new { element, idx })
.GroupBy(x => x.idx / blockSize, x => x.element)
.Select(b => b.ToArray())
.ToArray();
@sawilde
sawilde / Sort files
Created October 12, 2012 06:12
Take a list of files and sort them by name regardless of folder structure
$sorted = [IO.Directory]::GetFiles($path, "*.*", [System.IO.SearchOption]::AllDirectories) |
Select-Object @{Name="FullName"; Expression={$_}}, @{Name="FileName"; Expression={[IO.Path]::GetFileName($_)}} |
Sort-Object FileName
@sawilde
sawilde / gist:2419627
Created April 19, 2012 08:21
load in a CSV file and wrap any field that isn't already in quotes with quotes
class Program
{
/// <summary>
/// load in a CSV file and wrap any field that isn't in quotes with quotes
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
var reader = File.OpenText(Path.Combine(Directory.GetCurrentDirectory(),args[0]));