Skip to content

Instantly share code, notes, and snippets.

Thomas Levesque thomaslevesque

View GitHub Profile
@thomaslevesque
thomaslevesque / gist:274766d874ebf1769c48a203786725f3
Created Jul 24, 2018
Regex to fix SwaggerResponse attributes after migration to Swashbuckle 3.0.0
View gist:274766d874ebf1769c48a203786725f3
Pattern: \[SwaggerResponse\((?<code>\d+), (?<type>typeof\([A-Za-z\.\<\>]+\)), (?<desc>\"[^\"]+\")\)\]
Replacement: [SwaggerResponse(${code}, ${desc}, ${type})]
@thomaslevesque
thomaslevesque / additional.css
Created Aug 26, 2017
Additional CSS for wide-screen Twenty Fourteen Wordpress theme
View additional.css
pre {
padding: 0;
border: none;
}
article h3 {
font-size: 20px;
}
code {
@thomaslevesque
thomaslevesque / CSharpErrorsAndWarnings.md
Last active Sep 2, 2018
All C# errors and warnings
View CSharpErrorsAndWarnings.md

All C# errors and warnings

Parsed from the Roslyn source code using Roslyn.

Code Level Message
CS0006 Error Metadata file '{0}' could not be found
CS0009 Fatal Metadata file '{0}' could not be opened -- {1}
CS0012 Error The type '{0}' is defined in an assembly that is not referenced. You must add a reference to assembly '{1}'.
CS0016 Error Could not write to output file '{0}' -- '{1}'
@thomaslevesque
thomaslevesque / CSharpErrorCodes.cs
Created May 10, 2017
Generate "warnings as errors" ruleset from error code definitions in Roslyn source code
View CSharpErrorCodes.cs
void Main()
{
string errorCodesFileUrl = "https://raw.githubusercontent.com/dotnet/roslyn/master/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs";
string errorCodesFileContent = new WebClient().DownloadString(errorCodesFileUrl);
var syntaxTree = CSharpSyntaxTree.ParseText(errorCodesFileContent);
var root = syntaxTree.GetRoot();
var enumDeclaration =
root.DescendantNodes()
.OfType<EnumDeclarationSyntax>()
.First(e => e.Identifier.ValueText == "ErrorCode");
@thomaslevesque
thomaslevesque / ParseAuthChallenge.cs
Created Feb 23, 2017
Parsing HTTP authentication challenge with Sprache
View ParseAuthChallenge.cs
void Main()
{
ParseAndPrintChallenge(@"Bearer realm=""FooCorp"", error=invalid_token, error_description=""The access token has expired""");
}
void ParseAndPrintChallenge(string input)
{
var challenge = Grammar.Challenge.Parse(input);
Console.WriteLine($"Scheme: {challenge.Scheme}");
Console.WriteLine($"Parameters:");
View keybase.md

Keybase proof

I hereby claim:

  • I am thomaslevesque on github.
  • I am thomaslevesque (https://keybase.io/thomaslevesque) on keybase.
  • I have a public key whose fingerprint is 32C8 E72A EC90 6E8B 79BF 36C3 7AF5 E7A4 FE44 396B

To claim this, I am signing this object:

@thomaslevesque
thomaslevesque / FakeConfigurator.cs
Created Jun 9, 2016
Adapter to ease the migration from FakeItEasy 1.x to 2.0.0, to avoid modifying existing fake configurators.
View FakeConfigurator.cs
using FakeItEasy;
using FakeItEasy.Creation;
namespace TestUtilies
{
public abstract class FakeConfigurator<T> : FakeOptionsBuilder<T>
{
protected override void BuildOptions(IFakeOptions<T> options)
{
options.ConfigureFake(ConfigureFake);
@thomaslevesque
thomaslevesque / GitHubMarkdownShortcuts.user.js
Last active Feb 3, 2016
Keyboard shortcuts for GitHub markdown editor
View GitHubMarkdownShortcuts.user.js
// ==UserScript==
// @name GitHub Markdown shortcuts
// @namespace ThomasLevesque
// @include https://github.com/*
// @include https://gist.github.com/*
// @version 1
// @grant none
// ==/UserScript==
View gist:e1ccd9cef0a47e609a46
└─┬ aglio@2.2.0
├─┬ aglio-theme-olio@1.6.2
│ ├── coffee-script@1.10.0
│ ├── highlight.js@8.9.1
│ ├─┬ jade@1.11.0
│ │ ├── character-parser@1.2.1
│ │ ├─┬ clean-css@3.4.9
│ │ │ └─┬ commander@2.8.1
│ │ │ └── graceful-readlink@1.0.1
│ │ ├── commander@2.6.0
View gitconfig
[alias]
diffc = diff --cached
logg = log --graph
logg1 = log --graph --oneline
st = status
rc = rebase --continue
publish = !git push -u origin $(git rev-parse --abbrev-ref HEAD)
You can’t perform that action at this time.