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 suggestions.md
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
bgrainger / !results.md
Last active Aug 8, 2019
Benchmarking MySqlConnector DbBatch against MariaDB
View !results.md

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
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)
return E_INVALIDARG;
@bgrainger
bgrainger / ReservedWords.cs
Created Sep 12, 2018
MySQL 8 reserved words
View ReservedWords.cs
var reservedWords = new[]
{
"ACCESSIBLE",
"ADD",
"ALL",
"ALTER",
"ANALYZE",
"AND",
"AS",
"ASC",
@bgrainger
bgrainger / BibleWorksHebrew.md
Last active May 7, 2019
BibleWorks Hebrew Mapping Table
View BibleWorksHebrew.md
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("");
writer.WriteLine("namespace AdoNet.Specification.Tests");
writer.WriteLine("{");
@bgrainger
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("https://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html")).Content.ReadAsStringAsync();
var html8 = await (await httpClient.GetAsync("https://dev.mysql.com/doc/refman/8.0/en/error-messages-server.html")).Content.ReadAsStringAsync();
var valueNames = new Dictionary<int, string>();
foreach (MySqlErrorCode value in Enum.GetValues(typeof(MySqlErrorCode)))
{
var intValue = (int)value;
@bgrainger
bgrainger / BenchmarkResults.md
Last active Jan 29, 2019
Benchmark async/await options in C# 7
View BenchmarkResults.md
BenchmarkDotNet=v0.10.3.0, OS=Microsoft Windows 10.0.14393
Processor=Intel(R) Xeon(R) CPU E5-1650 v3 3.50GHz, ProcessorCount=12
Frequency=3410069 Hz, Resolution=293.2492 ns, Timer=TSC
dotnet cli version=1.0.1
  [Host]     : .NET Core 4.6.25009.03, 64bit RyuJIT
  DefaultJob : .NET Core 4.6.25009.03, 64bit RyuJIT

Method | Mean | StdDev | Gen 0 | Allocated

You can’t perform that action at this time.