Skip to content

Instantly share code, notes, and snippets.

View ScottHutchinson's full-sized avatar

Scott Hutchinson ScottHutchinson

  • ICI Services
  • Westlake Village, California
View GitHub Profile
@ScottHutchinson
ScottHutchinson / utility.h
Created January 28, 2020 22:14
A very fast split function in C++
/* Based on http://www.cplusplus.com/forum/beginner/114790/#msg626659
and https://github.com/fenbf/StringViewTests/blob/master/StringViewTest.cpp#L151,
which is the repo for this blog post: https://www.bfilipek.com/2018/07/string-view-perf-followup.html
*/
template<typename Out = std::vector<std::string>>
Out split(const std::string_view s, const char delim, const size_t maxFields = 0) {
Out elems;
size_t start{};
size_t end{};
size_t numFieldsParsed{};
@ScottHutchinson
ScottHutchinson / dotnetbuild.txt
Created December 31, 2019 18:20
dotnet build -v d output
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 12/31/2019 10:17:35 AM.
0>Resolving SDK 'Microsoft.NET.Sdk'...
Property reassignment: $(MSBuildProjectExtensionsPath)="C:\Users\scott\source\Exercism\users\7enderhead\fsharp\phone-number\obj\" (previous value: "obj\") at C:\Program Files\dotnet\sdk\3.0.100\Current\Microsoft.Common.props (56,5)
Property reassignment: $(MSBuildAllProjects)=";C:\Users\scott\source\Exercism\users\7enderhead\fsharp\phone-number\obj\PhoneNumber.fsproj.nuget.g.props;C:\Program Files\dotnet\sdk\3.0.100\FSharp\Microsoft.FSharp.NetSdk.props" (previous value: ";C:\Users\scott\source\Exercism\users\7enderhead\fsharp\phone-number\obj\PhoneNumber.fsproj.nuget.g.props") at C:\Program Files\dotnet\sdk\3.0.100\FSharp\Microsoft.FSharp.NetSdk.props (16,5)
Property reassignment: $(TargetsForTfmSpecificContentInPackage)=";PackTool;_PackProjectToolValidation" (previous value: ";PackToo
@ScottHutchinson
ScottHutchinson / removingskips.md
Created December 26, 2019 19:49
How to automate removing the skip argument from all the tests in VS Code
  1. Install the Replace Rules extension for VS Code.
  2. Save this setting to the settings.json file:
    "replacerules.rules": {
        "Remove skips": {
            "find": "(Skip = \"Remove to run test\")",
            "replace": "",
            "literal": true
        }
 }
#include <map>
using std::map;
/* This is a two-way (or bi-directional) map similar to the Boost bimap.
It enables a caller to look up value by key, or a key by value,
which makes it easy to translate to/from a pair of types.
For instance, we can retrieve the name of an enumerator or integer value
and translate it into an integer; and then to update it, we translate it
from integer back into its name to store in the config file.
@ScottHutchinson
ScottHutchinson / dotnet console output.txt
Created October 18, 2019 22:07
Elmish.WPF console output
Initial state:: { SomeGlobalState = false
DummyRoot =
{ Data = { Id = CounterId ee676ace-cd00-4619-8662-39ace6b843db
CounterValue = 0
StepSize = 1 }
Children =
[{ Data =
{ Id =
CounterId
ee676ace-cd00-4619-8662-39ace6b843db
@ScottHutchinson
ScottHutchinson / HelloWorldBolero.Server Run-time Error.txt
Created June 24, 2019 15:37
HelloWorldBolero.Server Run-time Error
$ dotnet run -p src/HelloWorldBolero.Server
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\hutchinsons\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
Creating key {50e71909-497e-402f-ae33-7c49352d927d} with creation date 2019-06-24 15:32:53Z, activation date 2019-06-24 15:32:53Z, and expiration date 2019-09-22 15:32:53Z.
info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39]
Writing data to file 'C:\Users\hutchinsons\AppData\Local\ASP.NET\DataProtection-Keys\key-50e71909-497e-402f-ae33-7c49352d927d.xml'.
Application startup exception: System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Authorization.IAuthorizeData' from assembly 'Microsoft.AspNetCore.Http.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Bolero.Rem
@ScottHutchinson
ScottHutchinson / extensions.bat
Created June 19, 2019 22:16
Batch file for installing VS Code extensions
:: call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code" --force --install-extension ajshort.include-autocomplete
call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code" --force --install-extension amazonwebservices.aws-toolkit-vscode
call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code" --force --install-extension austin.code-gnu-global
call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code" --force --install-extension dbaeumer.vscode-eslint
call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code" --force --install-extension eamodio.gitlens
call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code" --force --install-extension ecmel.vscode-html-css
call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code" --force --install-extension Flixs.vs-code-http-server-and-html-preview
call "C:\Users\hutchinsons\AppData\Local\Programs\Microsoft VS Code\bin\code"
@ScottHutchinson
ScottHutchinson / install-vsix.ps1
Last active January 19, 2024 15:21
PowerShell scripts for batch installing Visual Studio extensions
# Based on http://nuts4.net/post/automated-download-and-installation-of-visual-studio-extensions-via-powershell
param([String] $PackageName)
$ErrorActionPreference = "Stop"
$baseProtocol = "https:"
$baseHostName = "marketplace.visualstudio.com"
$Uri = "$($baseProtocol)//$($baseHostName)/items?itemName=$($PackageName)"
@ScottHutchinson
ScottHutchinson / errors.txt
Created December 17, 2018 20:40
Programming Microsoft ASP.NET MVC, 3rd Edition errors
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
1>C:\Users\Scott\Source\Mvc5bis\Lib\BookSamples.Components\ActionResults\HttpNotFoundResult.cs(6,39,6,59): error CS0246: The type or namespace name 'HttpStatusCodeResult' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\Scott\Source\Mvc5bis\Lib\BookSamples.Components\
@ScottHutchinson
ScottHutchinson / SplitCommaDelimitedLineWithQuotedValues.vb
Created October 4, 2018 18:01
SplitCommaDelimitedLineWithQuotedValues function
' hutch: 10/04/18. Added this function to enable an import file to contain a DX file path that includes commas.
Public Shared Function SplitCommaDelimitedLineWithQuotedValues(ByVal value As String, ByVal delimiter As Char) As String()
' Split using comma as the delimiter, but ignoring commas inside single quotes (')
Dim values = Regex.Split(value, ",(?!(?=[^']*'[^']*(?:'[^']*'[^']*)*$))")
' Trim spaces and single quotes from each item in values.
Dim ret = values.Select(Function(x) x.Trim(New Char() {" "c, "'"c})).ToArray()
Return ret
End Function
' Example call: Dim token As String() = SplitCommaDelimitedLineWithQuotedValues(line, ","c) 'token may start with space