Skip to content

Instantly share code, notes, and snippets.

View rmacfie's full-sized avatar
😎

Robert Macfie rmacfie

😎
  • Stockholm, Sweden
View GitHub Profile
@rmacfie
rmacfie / profiles.json
Last active March 27, 2020 11:15
Windows Terminal settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"profiles": {
"defaults": {
"startingDirectory": "C:\\Source",
"snapOnInput": true,
"closeOnExit": true,
"historySize": 9001,
"colorScheme": "VS Code",
@rmacfie
rmacfie / side-by-side.html
Last active May 8, 2017 16:41
side-by-side
<!DOCTYPE html>
<html>
<head>
<title>Side by Side</title>
<meta http-equiv="refresh" content="30" />
<style>
html {
box-sizing: border-box;
}
# bash completion
export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion"
@rmacfie
rmacfie / server.ts
Created October 6, 2016 17:16
Convert application/octet-stream upload to ReadableStream
import * as stream from "stream";
import * as express from "express";
import * as bodyParser from "body-parser";
const app = express();
app.use(bodyParser.raw());
app.use(bodyParser.json());
app.post("/upload", (req: express.Request, res: express.Response, next: express.NextFunction) => {
@rmacfie
rmacfie / SimpleLogger.cs
Last active May 14, 2016 11:21
Simple request logging in Asp.Net Core, suitable for showing in the console while developing
using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Builder
{
public static class SimpleLogger
{
const string LOG_NAME = "MyProject.SimpleLogger";
const string LOG_FORMAT = "{0} | {1}ms | {2} | {3} {4}";
@rmacfie
rmacfie / HttpsEnforcer.cs
Last active May 14, 2016 11:22
Enforce HTTPS in Asp.Net Core
using System;
namespace Microsoft.AspNet.Builder
{
public static class HttpsEnforcer
{
public static IApplicationBuilder UseHttpsEnforcer(this IApplicationBuilder app)
{
Func<RequestDelegate, RequestDelegate> middleware = next => async context =>
{
@rmacfie
rmacfie / DomainEnforcer.cs
Last active May 14, 2016 11:23
Enforce domain name in Asp.Net Core
using System;
namespace Microsoft.AspNet.Builder
{
public static class DomainEnforcer
{
public static IApplicationBuilder UseDomainEnforcer(this IApplicationBuilder app, string domainToEnforce)
{
if (string.IsNullOrEmpty(domainToEnforce))
throw new ArgumentNullException(nameof(domainToEnforce));
@rmacfie
rmacfie / azure-msdeploy-folder.cmd
Last active November 14, 2015 18:16
Simple folder deploy through Web Deploy (MSDeploy)
:: The following variables are required:
SET AZDEPLOY_SOURCE=C:\Apps\myapp\dist
SET AZDEPLOY_APP=myapp
SET AZDEPLOY_PASSWORD=mypassword
:: The password can be extracted from the publish settings you download from the Azure portal
msdeploy.exe ^
-verb:sync ^
-source:contentPath="%AZDEPLOY_SOURCE%" ^
@rmacfie
rmacfie / MediatRExtensions.cs
Last active July 12, 2022 12:42
Register MediatR handlers in Asp.Net 5 / vNext / Core
namespace Microsoft.AspNet.Builder
{
public static class MediatRExtensions
{
public static IServiceCollection AddMediatR(this IServiceCollection services, params Assembly[] handlerAssemblies)
{
services.AddTransient<IMediator>(x => new Mediator(x.GetService<SingleInstanceFactory>(), x.GetService<MultiInstanceFactory>()));
services.AddTransient<SingleInstanceFactory>(x => t => x.GetRequiredService(t));
services.AddTransient<MultiInstanceFactory>(x => t => x.GetServices(t));
@rmacfie
rmacfie / gist:2429c6e9bca7e0168cfd
Last active August 29, 2015 14:14
Boxstarter
choco install notepad2-mod
choco install conemu
choco install 7zip
choco install googlechrome
choco install kdiff3
choco install gitextensions
choco install git-credential-winstore
choco install nodejs
choco install visualstudiocode