Skip to content

Instantly share code, notes, and snippets.

View JamesNK's full-sized avatar

James Newton-King JamesNK

View GitHub Profile
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
#region License
// Copyright (c) 2007 James Newton-King
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
@JamesNK
JamesNK / wow.cs
Last active August 29, 2015 14:02
DSON (Doge Serialized Object Notation): a data-interchange format that is easy for Shiba Inu dogs to read and write - https://github.com/JamesNK/Newtonsoft.Dson
var data = new
{
hello = "world",
people = new[] { "James", "Brendan", "Amy" }
};
string dson = DsonConvert.SerializeObject(data, Formatting.Indented);
// such
// "hello" is "world",
// "people" is so
@JamesNK
JamesNK / release-git.cmd
Last active August 29, 2015 14:10
release-git.cmd
set OLDDIR=%CD%
rmdir /s /q .\Working
mkdir .\Working
chdir Working
call git clone git://github.com/JamesNK/Newtonsoft.Json.git
rmdir Newtonsoft.Json\.git /s /q
chdir Newtonsoft.Json\Build
@JamesNK
JamesNK / JsonMetroUpgrade.cs
Created March 31, 2012 23:11
Json.NET Metro Upgrade Kit
public class MetroPropertyNameResolver : DefaultContractResolver
{
protected internal override string ResolvePropertyName(string propertyName)
{
return ":::" + propertyName.ToUpper() + ":::";
}
}
public class MetroStringConverter : JsonConverter
{
@JamesNK
JamesNK / release-git.cmd
Created February 18, 2013 22:57
Clear working directory, get latest version of Json.NET from GitHub, build full version of Json.NET by calling runbuild.cmd with arguments.
set OLDDIR=%CD%
rmdir /s /q .\Working
mkdir .\Working
chdir Working
call git clone git://github.com/JamesNK/Newtonsoft.Json.git
rmdir Newtonsoft.Json\.git /s /q
chdir Newtonsoft.Json\Build
[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 / Program.cs
Created March 24, 2017 00:21
Json.NET double tester - 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
{
[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
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
</Project>