Skip to content

Instantly share code, notes, and snippets.

Ready to kick ass and chew bubble gum, and i'm all outta gum.

Matt Phillips programatt

Ready to kick ass and chew bubble gum, and i'm all outta gum.
Block or report user

Report or block programatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
programatt / inlineauth.cs
Last active Mar 29, 2017
inline middleware that does the auth process
View inlineauth.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System;
using System.Net;
public static class BuilderExtensions
public static IApplicationBuilder UseSillyAuthentication(this IApplicationBuilder app,Func<HttpContext,bool> authorizeFunc)
app.Use(async (context, next) =>
View AuthenticationMiddleware.cs
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
View startupmethods.cs
.Run(RequestDelegate handler);
.Use(Func<RequestDelegate,RequestDelegate> inlineMiddleware);
.Map(PathString pathMatch,Action<IApplicationBuilder> configurationAction);
.MapWhen(Func<HttpContext,bool> predicate,Action<IApplicationBuilder> configurationAction);
View Dockerfile
FROM microsoft/dotnet:1.0.0-preview2-sdk
COPY . /dotnetapp
WORKDIR /dotnetapp
RUN dotnet restore -v Verbose
RUN dotnet build
EXPOSE 5000/tcp
CMD ["dotnet","run","--server.urls="]
View gist:08a69faf8089996bf17d
* Bootstrap v3.2
* Copyright 2014 Twitter, Inc
* Licensed under the Apache License v2.0
* Designed and built with all the love in the world by @mdo and @fat.
* BootSwatchr built and provided by @DrewStrickland
*//*! normalize.css v3.0.1 | MIT License | */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border
programatt /
Last active Aug 29, 2015
Setup clojure on a debian variant of linux
sudo apt-get update
sudo apt-get install openjdk-7-jdk
mkdir temp
cd temp
sudo mv lein /usr/bin/lein
sudo chmod a+x /usr/bin/lein
cd ~
rm -rf temp
programatt / function_composition.hs
Created Jan 22, 2014
Haskell Function Composition with multiple arguments example
View function_composition.hs
f :: [Bool] -> Bool
f = and
g :: (Eq a) => ([a],[a]) -> [Bool]
g = uncurry $ zipWith (==)
h :: (Eq a) => ([a],[a]) -> Bool
h = f . g
f' :: [Bool] -> Bool
programatt / rps.hs
Created Jan 8, 2014
rock paper scissors in haskell using StateT
View rps.hs
import System.Random
import Control.Monad.State
data Hand = Rock | Scissors | Paper deriving(Show,Eq)
data Result = Win | Lose | Tie deriving(Show)
type Score = (Int,Int)
fight :: Hand -> Hand -> Result
fight h1 h2 | h1 == h2 = Tie
| h1 == Rock && h2 == Scissors = Win
View boot.s
; boot.s -- Kernel start location. Also defines multiboot header.
; Based on Bran's kernel development tutorial file start.asm
MBOOT_PAGE_ALIGN equ 1<<0 ; Load kernel and modules on a page boundary
MBOOT_MEM_INFO equ 1<<1 ; Provide your kernel with memory info
MBOOT_HEADER_MAGIC equ 0x1BADB002 ; Multiboot Magic value
; NOTE: We do not use MBOOT_AOUT_KLUDGE. It means that GRUB does not
; pass us a symbol table.
programatt / TestableTypeFactory.cs
Created Aug 23, 2012
Any order mocked construction parameters
View TestableTypeFactory.cs
using System;
using System.Linq;
using Moq;
using Xunit;
namespace Tests.UnitTests.Services
public class TestableTypeFactory
public static T GetType<T>(params object[] constructorParameters)
You can’t perform that action at this time.