Instantly share code, notes, and snippets.

View README.md

work in progress

using bootstrap 4, importing fontawesome but not using it yet

View grapevine-custom-logger.md

Customizing The Grapevine 4 Logger

First, create a class that implements the IGrapevineLogger interface.

public class MyCustomLogger : IGrapevineLogger
{
    // implementation details
}
View grapevine-input-validation.cs
// the context will be passed into the method automatically by the router
server.Router.BeforeRouting += context =>
{
// Do your input validation here
if (!context.Request.Payload.Contains("elephant"))
{
// by sending a response to the request, no additional processing will occur.
context.Response.SendResponse(HttpStatusCode.BadRequest, "no elephants allowed");
}
View grapevine-register-singleton.md

Create the class that manages the list of APIs as a singleton.

public class ApiKeyManager
{
    private static ApiKeyManager _instance;
    public readonly List<string> ApiKeys = new List<string>();

    private ApiKeyManager() {}
View grapevine-route-params.md

To set up a route that parses parameters from the path info:

[RestRoute(HttpMethod = HttpMethod.GET, PathInfo = "/cars/[carId]")]
public IHttpContext GetCarById(IHttpContext context)
{
	// Get the car id from the incoming context:
	Console.WriteLine(context.Request.PathParameters["carId"]);
}
View .gitconfig
[user]
name = Your Name
email = your.name@company.com
[alias]
cm = commit -m
co = checkout
find = log --pretty=\"format:%Cgreen%H %Cblue%s\" --name-status --grep
lola = log --graph --decorate --pretty=oneline --abbrev-commit
nix = clean -dfx
personal = config user.email "you@personal-email.com"
View open-cover-xunit.bat
@ECHO OFF
REM OpenCover-xunit.bat
REM Run opencover against xunit tests in your test project and show report of code coverage
Set SearchDirectory=%~dp0Grapevine.Tests\bin\Debug
SET DllContainingTests=%~dp0Grapevine.Tests\bin\Debug\Grapevine.Tests.dll
REM *** IMPORTANT - Change DllContainingTests variable (above) to point to the DLL
View .gitconfig
[alias]
personal = config user.email "personal@emailaddress.com"
View xml-element-order.md

XML Element Ordering

TL;DR

If your XSD is using the xs:sequence indicator, then the order of the elements in that complex type matters, and they should be included in the order listed inside the tag.

XML Specification

Generally speaking, the order in which child elements appear inside their parent element container in XML shouldn't matter. As such, the following two examples would be considered semantically equivalent XML.

View using-ntlm-with-nodejs.md

Using NTLM in Node.js

Add a project dependency for express-ntlm. In your express configuration, require in this package.

var app = require('express');
var ntlm = require('express-ntlm');

Just before adding routes to the app (after all the body parsing and static references, etc.):