Instantly share code, notes, and snippets.

View Client.cs
// Asynchronous Client Socket Example
// http://msdn.microsoft.com/en-us/library/bew39x2a.aspx
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
// State object for receiving data from remote device.
View README.md

Using the line define('NOBLOGREDIRECT', '%siteurl%'); in your wp-config.php makes it so that when someone enters a subdomain that does not exist on your site, it will redirect to whatever url you specify. You can use this to have it either go to a specific FAQ page or directly back to the main root installation, anywhere you want to direct it. the variable %siteurl% can be replaced; for example define('NOBLOGREDIRECT', 'http://frumph.net/FAQ/site-create');

When someone in their browser tries to go to a subdomain that doesn't exist (for example, http://badsubdomain.frumph.net/), they will be redirected to what is defined for NOBLOGREDIRECT.

Without using NOBLOGREDIRECT the (for example) http://badsubdomain.frumph.net/ – which is a subdomain that doesn't exist would direct to the signup page asking which reports whether or not the user can create the bad subdomain in question. This is fine, there's nothing wrong with it redirecting to the signup page if someone put in a bad url. However, those of

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"