Skip to content

Instantly share code, notes, and snippets.

Bradley Grainger bgrainger

Block or report user

Report or block bgrainger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RuntimeHelpers.cs
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Runtime.CompilerServices
internal static class RuntimeHelpers
/// <summary>
/// Slices the specified array using the specified range.
User Input Bing Suggestion
man msn
Yah Yahoo
prostrate prostate
pray city party city
hard rich heaven hard rock heaven
ten virgin teen virgin
free born free porn
bgrainger / !
Last active Aug 8, 2019
Benchmarking MySqlConnector DbBatch against MariaDB
View !

MySQL 8.0.17

Method Mean Error StdDev
Command 403.4 µs 7.959 µs 19.069 µs
Commands 775.9 µs 15.357 µs 28.465 µs
PreparedCommand 359.8 µs 4.708 µs 4.174 µs
PreparedCommands 726.8 µs 14.508 µs 14.899 µs
BatchCommand 390.2 µs 7.572 µs 7.776 µs
BatchCommands 390.5 µs 7.548 µs 10.077 µs
bgrainger / ReadFileFragment.cpp
Created Jun 3, 2019
Improving WPF Text Display Performance
View ReadFileFragment.cpp
HRESULT FontFileStream::ReadFileFragment(const void ** fragmentStart, UINT64 fileOffset, UINT64 fragmentSize, void ** fragmentContext)
if (fragmentStart != nullptr)
*fragmentStart = nullptr;
if (fragmentContext != nullptr)
*fragmentContext = nullptr;
if (fragmentStart == nullptr || fragmentContext == nullptr)
return E_POINTER;
if (fileOffset >= m_length || fileOffset + fragmentSize > m_length)
bgrainger / ReservedWords.cs
Created Sep 12, 2018
MySQL 8 reserved words
View ReservedWords.cs
var reservedWords = new[]
bgrainger /
Last active May 7, 2019
BibleWorks Hebrew Mapping Table
View GenerateGetValueConversionTestBase.cs
void Main()
using (var writer = new StreamWriter(@"GetValueConversionTestBase.g.cs"))
writer.WriteLine("using System;");
writer.WriteLine("using System.CodeDom.Compiler;");
writer.WriteLine("using System.Data;");
writer.WriteLine("using Xunit;");
writer.WriteLine("namespace AdoNet.Specification.Tests");
bgrainger / mysql.cs
Created Sep 15, 2017
MySQL UPDATE with OUT parameter
View mysql.cs
// Make sure to set AllowUserVariables=true in connection string
private string SqlLogUpdate => _sqlLogUpdate ?? (_sqlLogUpdate = $@"
Update {_tableName}
Set DuplicateCount = DuplicateCount + @DuplicateCount,
GUID = (@newGUID := GUID) -- set the variable here
Where ErrorHash = @ErrorHash; -- AND ...
Select @newGUID; -- still have to select it to get it back";
protected override bool LogError(Error error)
View FormattableSql.cs
void Main()
var name = "test";
var state = "WA";
var cmd = new MySqlConnection().CreateCommand($"SELECT * FROM Customers WHERE Name = {name} AND State = {state};");
// cmd.CommandText == "SELECT * FROM Customers WHERE Name = @p0 AND State = @p1;"
public static class DbExtensions
View GenerateMySqlErrorCode.cs
async Task Main()
var httpClient = new HttpClient();
var html57 = await (await httpClient.GetAsync("")).Content.ReadAsStringAsync();
var html8 = await (await httpClient.GetAsync("")).Content.ReadAsStringAsync();
var valueNames = new Dictionary<int, string>();
foreach (MySqlErrorCode value in Enum.GetValues(typeof(MySqlErrorCode)))
var intValue = (int)value;
You can’t perform that action at this time.