Skip to content

Instantly share code, notes, and snippets.

@thomaslevesque
thomaslevesque / gitconfig
Last active March 28, 2022 12:54
Useful git aliases
[repo]
defaultRemoteName = origin
mainBranchName = master
[alias]
diffc = diff --cached
logg1 = log --graph --oneline
current-branch = rev-parse --abbrev-ref HEAD
publish = !git push -u $(git config repo.defaultRemoteName) $(git current-branch)
finish-branch = !branchName=$(git current-branch) && git fetch $(git config repo.defaultRemoteName) $(git config repo.mainBranchName):$(git config repo.mainBranchName) && git checkout $(git config repo.mainBranchName) && git branch -d $branchName && git fetch -p $(git config repo.defaultRemoteName)
@thomaslevesque
thomaslevesque / gist:e1ccd9cef0a47e609a46
Created January 15, 2016 13:34
aglio dependencies... OMG!
└─┬ [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
@thomaslevesque
thomaslevesque / GitHubMarkdownShortcuts.user.js
Last active April 14, 2021 00:33
Keyboard shortcuts for GitHub markdown editor
// ==UserScript==
// @name GitHub Markdown shortcuts
// @namespace ThomasLevesque
// @include https://github.com/*
// @include https://gist.github.com/*
// @version 1
// @grant none
// ==/UserScript==
@thomaslevesque
thomaslevesque / FakeConfigurator.cs
Created June 9, 2016 17:05
Adapter to ease the migration from FakeItEasy 1.x to 2.0.0, to avoid modifying existing fake configurators.
using FakeItEasy;
using FakeItEasy.Creation;
namespace TestUtilies
{
public abstract class FakeConfigurator<T> : FakeOptionsBuilder<T>
{
protected override void BuildOptions(IFakeOptions<T> options)
{
options.ConfigureFake(ConfigureFake);

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 / ParseAuthChallenge.cs
Created February 23, 2017 00:56
Parsing HTTP authentication challenge with Sprache
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:");
@thomaslevesque
thomaslevesque / CSharpErrorCodes.cs
Created May 10, 2017 01:10
Generate "warnings as errors" ruleset from error code definitions in Roslyn source code
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 / CSharpErrorsAndWarnings.md
Last active October 24, 2025 06:13
All C# errors and warnings. NOTE: this list is out of date. See https://github.com/thomaslevesque/GenerateCSharpErrors/blob/master/CSharpErrorsAndWarnings.md for a more recent version

All C# errors and warnings

Parsed from the Roslyn source code using Roslyn.

Code Severity 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 / additional.css
Created August 26, 2017 14:20
Additional CSS for wide-screen Twenty Fourteen Wordpress theme
pre {
padding: 0;
border: none;
}
article h3 {
font-size: 20px;
}
code {
@thomaslevesque
thomaslevesque / gist:274766d874ebf1769c48a203786725f3
Created July 24, 2018 10:05
Regex to fix SwaggerResponse attributes after migration to Swashbuckle 3.0.0
Pattern: \[SwaggerResponse\((?<code>\d+), (?<type>typeof\([A-Za-z\.\<\>]+\)), (?<desc>\"[^\"]+\")\)\]
Replacement: [SwaggerResponse(${code}, ${desc}, ${type})]