Skip to content

Instantly share code, notes, and snippets.

Avatar
🐴
It's complicated

James Newton-King JamesNK

🐴
It's complicated
View GitHub Profile
View protobuf writing benchmarks windows: before and after
BenchmarkDotNet=v0.11.4, OS=Windows 10.0.18363
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET Core SDK=3.1.400-preview-015151
[Host] : .NET Core 2.1.17 (CoreCLR 4.6.28619.01, CoreFX 4.6.28619.01), 64bit RyuJIT
DefaultJob : .NET Core 2.1.17 (CoreCLR 4.6.28619.01, CoreFX 4.6.28619.01), 64bit RyuJIT
Before:
| Method | messageCount | Mean | Error | StdDev | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
|--------------------------------------------------------------------- |------------- |--------------:|--------------:|--------------:|------------:|------------:|------------:|--------------------:|
View benchmark.cs
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
static class Program
View GrpcEventSource.cs
#region Copyright notice and license
// Copyright 2019 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
@JamesNK
JamesNK / ZalgoParameterTransformer.cs
Created Sep 26, 2018
ZalgoParameterTransformer.cs
View ZalgoParameterTransformer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Routing;
namespace MvcSandbox
{
View ConsoleApp2.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
</Project>
View CanCloseStreamMethodEarly_json_ServerSentEvents_default.log
[2018-05-21T23:17:57] [TestLifetime] [Information] Starting test "CanCloseStreamMethodEarly_json_ServerSentEvents_default"
[0.000s] [ServerLogScope] [Information] Server log scope started.
[0.000s] [Microsoft.AspNetCore.SignalR.Client.HubConnection] [Verbose] Waiting on Connection Lock in "StartAsyncCore" ("/_/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs":239).
[0.000s] [Microsoft.AspNetCore.SignalR.Client.HubConnection] [Debug] Starting HubConnection.
[0.001s] [Microsoft.AspNetCore.Http.Connections.Client.HttpConnection] [Debug] Starting HttpConnection.
[0.001s] [Microsoft.AspNetCore.Http.Connections.Client.HttpConnection] [Debug] Establishing connection with server at 'http://127.0.0.1:1903/default'.
[0.002s] [Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler] [Verbose] Sending HTTP request "POST" 'http://127.0.0.1:1903/default/negotiate'.
[0.004s] [SERVER Microsoft.AspNetCore.Server.Kestrel] [Debug] Connection id "0HLDVE3S42R5H" started.
[0.004s] [SERVER Micro
@JamesNK
JamesNK / validate-schema.ps1
Last active May 25, 2020
Validate Schema from PowerShell
View validate-schema.ps1
$ErrorActionPreference = "Stop"
$NewtonsoftJsonPath = Resolve-Path -Path "bin\Newtonsoft.Json.dll"
$NewtonsoftJsonSchemaPath = Resolve-Path -Path "bin\Newtonsoft.Json.Schema.dll"
Add-Type -Path $NewtonsoftJsonPath
Add-Type -Path $NewtonsoftJsonSchemaPath
$source = @'
public class Validator
@JamesNK
JamesNK / Program.cs
Created Mar 24, 2017
Json.NET double tester - Program.cs
View Program.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace ConsoleApp1
{
View gist:afb3f15771d6f09b2da01a157cff32ea
[Test]
public void IsMultipleTests()
{
// true
Console.WriteLine(IsMultiple(0.0075, 0.0001));
Console.WriteLine(IsMultiple(500.4, 0.001));
Console.WriteLine(IsMultiple(500.4, 0.0001));
Console.WriteLine(IsMultiple(500.4, 0.00001));
Console.WriteLine(IsMultiple(500.4, 0.000001));
Console.WriteLine(IsMultiple(500.4, 0.0000001));
@JamesNK
JamesNK / Newtonsoft.Json.nuspec
Last active Sep 4, 2015
The Great Newtonsoft.Json.nuspec Collaboration
View Newtonsoft.Json.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Newtonsoft.Json</id>
<version></version>
<title>Json.NET</title>
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
<authors>James Newton-King</authors>
<language>en-US</language>
<projectUrl>http://www.newtonsoft.com/json</projectUrl>
You can’t perform that action at this time.