Skip to content

Instantly share code, notes, and snippets.

View JamesNK's full-sized avatar

James Newton-King JamesNK

View GitHub Profile
[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 March 22, 2021 04:33
The Great Newtonsoft.Json.nuspec Collaboration
<?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>
@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 / 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
#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 / 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
@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
{