Skip to content

Instantly share code, notes, and snippets.

var gist = function(userName, gistId){
return 'https://gist.github.com/' + userName + '/' + gistId + '.js';
}
@iwannabebot
iwannabebot / SwaggerUIOAuth2MiddlewarwStartup.cs
Last active May 13, 2018 08:01
Add OAuth2/OpenID compatible middleware to Swagger
public void ConfigureServices(IServiceCollection services)
{
// Other settings
services
.AddSwaggerGen(c =>
{
// Other settings
c.AddSecurityDefinition("oauth2", new OAuth2Scheme
{
Type = "oauth2",
@iwannabebot
iwannabebot / SwaggerUIOAuth2HeaderStartup.cs
Last active May 13, 2018 08:13
Add Bearer token in header of a Swagger request
public void ConfigureServices(IServiceCollection services)
{
services
.AddSwaggerGen(c =>
{
c.OperationFilter<AddAuthorizationHeaderParameterOperationFilter>();
});
}
/// <summary>
@iwannabebot
iwannabebot / UpdateLayout.cshtml
Created September 10, 2018 13:30
To apply material theme in your application, you need to add the following code in _Layout.cshtml
// If using tag helpers
<c1-styles theme="material" />
// If using html helpers
@Html.C1().Styles().Theme("material")
@iwannabebot
iwannabebot / UpdateLayout.cshtml
Created September 10, 2018 13:33
Include the Material Lite JavaScript file in _Layout page of your application.
<script defer src="https://code.getmdl.io/1.1.1/material.min.js"></script>
@iwannabebot
iwannabebot / UpdateLayout.cshtml
Created September 10, 2018 13:34
Use our theme builder to decide some colour combinations. After deciding some arbitrary colour combination, you would be provided with a code to include in your layout page.
<link rel="stylesheet" href="https://code.getmdl.io/1.1.1/material.deep_purple-pink.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/themes/material/wijmo.theme.material.deep_purple-pink.min.css" />
@iwannabebot
iwannabebot / UpdateLayout.cshtml
Created September 10, 2018 13:35
You can optionally include Material Icons in your application:
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
@iwannabebot
iwannabebot / materialformat.txt
Last active September 10, 2018 18:20
Material themes are written in a specific format to allow several combinations of primary/accent colours
material[.{{primary_colour}}-{{secondary_colour}}]
example:
material
material.indigo-pink
material.green-red
@iwannabebot
iwannabebot / UIHelper.cs
Created October 17, 2018 09:07
Search a WPF control hierarchy for controls that match a given name or type
/// <summary>
/// Finds a Child of a given item in the visual tree.
/// </summary>
/// <param name="parent">A direct parent of the queried item.</param>
/// <typeparam name="T">The type of the queried item.</typeparam>
/// <param name="childName">x:Name or Name of child. </param>
/// <returns>The first parent item that matches the submitted type parameter.
/// If not matching item can be found,
/// a null parent is being returned.</returns>
/// Usage:
@iwannabebot
iwannabebot / MimeService.cs
Last active December 24, 2018 05:29
A C# utility class that gives your the Mime type from the file extension.
using System;
using System.Collections.Generic;
using System.Web;
namespace Iwannabebot.Utility.Web
{
public class MimeService
{
public static string Get(string extension)
{