Skip to content

Instantly share code, notes, and snippets.

@andy-uq
andy-uq / JsonContent.cs
Created August 8, 2018 03:42
A class for serialising content with a custom JSON serialiser
public class JsonContent : HttpContent
{
private static readonly JsonSerializer s_defaultDecisionEngineJsonSerialiser = JsonSerializer.Create(new DecisionEngineJsonSerializerSettings());
private readonly Lazy<JsonSerializer> _serialiser;
private readonly object _value;
public Encoding Encoding { get; }
void Main()
{
var storage = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=en7343;AccountKey=VdJRm1PbyQ8YOrd3gR+CMcS5YQge6H4XMMaNpR2DBhDxV/0A/lQT+SXnNnQbx0xqyLTQVnY5+DwwEYCXWqFm3g==;EndpointSuffix=core.windows.net");
var client = storage.CreateCloudBlobClient();
var container = client.GetContainerReference("test-06");
container.CreateIfNotExists();
CreateData(container);
ReadData(container);
@andy-uq
andy-uq / MicrosoftExtensionsLoggingSpy.csproj
Created June 1, 2017 03:58
Reads ETW events from Microsoft.Extensions.Logging
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="1.0.41" />
</ItemGroup>
@andy-uq
andy-uq / sync nuspec with references.cs
Created May 18, 2017 21:35
Updates a nuspec to reflect the references in the csproj
foreach (var csproj in Directory.GetFiles(@"C:\Git\_InternalTools\Nephele", "*.csproj", SearchOption.AllDirectories))
{
var nuspecFileInfo = new FileInfo(Path.ChangeExtension(csproj, ".nuspec"));
if (!nuspecFileInfo.Exists)
continue;
Console.WriteLine($"Inspecting {nuspecFileInfo.Name}");
var xNuspec = XDocument.Load(nuspecFileInfo.FullName);
var xMetaData = xNuspec.XPathSelectElement("package/metadata");
var xDependencies = xMetaData.XPathSelectElement("dependencies");
<Query Kind="Program">
<Namespace>System.Threading.Tasks</Namespace>
</Query>
const string folder = @"C:\Git\_InternalTools\Nephele";
const string assemblyPath = @"bin\debug\net46";
void Main()
{
foreach (var filename in Directory.GetFiles(folder, "*.nuspec", SearchOption.AllDirectories))
public class DocumentDb
{
private readonly DocumentClient _documentDb;
private readonly string _databaseId;
public DocumentDb(string endPoint, string authKey, string databaseId)
{
_databaseId = databaseId;
_documentDb = new DocumentClient(new Uri(endPoint), authKey);
}
@andy-uq
andy-uq / repackage.linq
Last active May 18, 2017 05:27
Convert VS2015 project to 2017
<Query Kind="Program">
<NuGetReference>NuGet.Core</NuGetReference>
<Namespace>NuGet</Namespace>
<Namespace>System.Runtime.Versioning</Namespace>
</Query>
const string folder = @"C:\Git\_InternalTools\Nephele";
void Main()
{
CAST(CAST(newid() AS binary(10)) + CAST(GETDATE() AS binary(6)) AS uniqueidentifier)
@andy-uq
andy-uq / GetBuildDirectory.cs
Last active August 29, 2015 14:20
Return the current solution directory, useful for tests
public static string GetBuildDirectory()
{
var solution = Environment.GetEnvironmentVariable("NCrunch.OriginalSolutionPath");
if (!string.IsNullOrEmpty(solution))
return Path.GetDirectoryName(solution);
var teamCityLocation = Environment.GetEnvironmentVariable("teamcity.build.checkoutDir");
if (!string.IsNullOrEmpty(teamCityLocation))
{
return teamCityLocation;
@andy-uq
andy-uq / README.md
Last active August 29, 2015 14:20 — forked from mbostock/.block