Skip to content

Instantly share code, notes, and snippets.

View stephenpatten's full-sized avatar

Stephen Patten stephenpatten

View GitHub Profile
@stephenpatten
stephenpatten / MobyLinux.ps1
Created November 17, 2018 21:13 — forked from biggyspender/MobyLinux.ps1
Set DockerNAT switch to be a private network
# See comment lines prefixed with ADDED
# It might be necessary to delete the existing DockerNAT switch in hyper-v manager
<#
.SYNOPSIS
Manages a MobyLinux VM to run Linux Docker on Hyper-V
.DESCRIPTION
Creates/Destroys/Starts/Stops A MobyLinux VM to run Docker on Hyper-V
.PARAMETER VmName
@stephenpatten
stephenpatten / GitHub-Forking.md
Last active November 4, 2018 18:15 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Note: Read the comments section of the original gist, it has some really good feedback.

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fo

@stephenpatten
stephenpatten / AutofacFluentValidationModule.cs
Created October 15, 2018 23:47 — forked from ShawInnes/AutofacFluentValidationModule.cs
Autofac Fluent Validation Module (MVC 5)
using Autofac;
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebSite
{
@stephenpatten
stephenpatten / AutofacValidatorFactory.cs
Created October 15, 2018 23:46 — forked from jasonmitchell/AutofacValidatorFactory.cs
Integrating Fluent Validation with Web API using Autofac. Full example: https://github.com/jasonmitchell/fluentvalidation-webapi-autofac
using System;
using Autofac;
using FluentValidation;
namespace Sample.Web.Infrastructure
{
public class AutofacValidatorFactory : ValidatorFactoryBase
{
private readonly IComponentContext _context;
@stephenpatten
stephenpatten / remove-docker-containers.md
Created September 6, 2018 12:36 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images

May 8, 2018

I wrote this four years ago, so instead use this command:

$ docker rmi $(docker images -q -f dangling=true)
@stephenpatten
stephenpatten / Program.cs
Created August 2, 2018 15:34 — forked from janpieterz/Program.cs
Serilog and Topshelf
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Serilog;
using Serilog.Extras.Topshelf;
using Topshelf;
using Topshelf.Logging;
namespace ConsoleApplication1
{
https://forums.manning.com/posts/list/34881.page
#help
docker help
# look for image, then runs it
docker run <account>/hello_world
# Based on trying to get elastic on windows to work. from this blog post:
@stephenpatten
stephenpatten / README.md
Created June 25, 2018 21:11 — forked from aaronk6/README.md
launchUri

Cross-browser implementation of navigator.msLaunchUri

Microsoft’s navigator.msLaunchUri method only works in Internet Explorer on Windows 8. Therefore I came up with a (nearly) cross-browser implementation that uses the native msLaunchUri when it’s available and falls back to adventurous hacks when running in other browsers.

Description

launchUri (uri, successCallback, noHandlerCallback, unknownCallback)
@stephenpatten
stephenpatten / .java.env.sh
Created June 15, 2018 04:22 — forked from lance/.java.env.sh
Java version switcher
# Props to qmx and abstractj for the inspiration
#
# Put this file in your home directory and these lines to .profile
# if [[ -f "$HOME/.java.env" ]]; then
# source "$HOME/.java.env";
# fi
VERSION=$1
if [ ! -n "$VERSION" ]
@stephenpatten
stephenpatten / retry.cs
Created May 11, 2018 19:27 — forked from benhysell/retry.cs
Polly - Back Off and Retry on Error http client
//Retry http with a back off on failure
await Policy.Handle<HttpRequestException>().WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)))
.ExecuteAsync(async () =>
{
var result = await httpClient.GetAsync("api/CallToServer/" + varibleToSendToServer, cancellationToken);
if (result.IsSuccessStatusCode)
{
returnValue = await result.Content.ReadAsAsync<List<Results>>(token);
}