Skip to content

Instantly share code, notes, and snippets.

View tiesont's full-sized avatar

Tieson Trowbridge tiesont

View GitHub Profile
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Microsoft.Internal.Web.Utils;
using Microsoft.Web.Helpers.Resources;
namespace YourNamespaceHere
@tiesont
tiesont / PasswordUtility.cs
Last active January 5, 2017 05:51
This is the Crypto class from System.Web, modified to remove globalization support (which is the only dependency Crypto has on System.Web). It also adds an optional parameter to the hash and verify methods to allow callers to increase the hash iteration count. Everything else is unchanged.
using System;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
public class PasswordUtility
{
// Original Version Copyright:
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Original License: http://www.apache.org/licenses/LICENSE-2.0
@tiesont
tiesont / RouteMapsSansHome.cs
Created January 10, 2017 21:09
Demonstrates how to remove "home" from routing without needing to explicitly map other controllers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace MyNamespace
{
public class RouteConfig
@tiesont
tiesont / so-greyish.css
Created February 8, 2017 07:17
Stack Overflow new navbar tweak - greyish
@-moz-document domain("stackoverflow.com") {
/* Uncomment if removing sticky header */
/*body.newheader {
padding-top: 0;
}*/
.so-header {
background-color: #f3f3f3;
/* Uncomment to remove sticky header */
/*position: relative;*/
@tiesont
tiesont / nav-wizard.bootstrap.css
Last active February 20, 2018 14:32 — forked from bjcull/nav-wizard.bootstrap.css
Wizard style navigation tabs for bootstrap, updated for Bootstrap 4. Demo: https://jsfiddle.net/dss1mjqf/
.nav-pills.nav-wizard > li
{
position: relative;
overflow: visible;
border-right: 15px solid transparent;
border-left: 15px solid transparent;
}
.nav-pills.nav-wizard > li + li
{
@tiesont
tiesont / DbContextExtensions.cs
Last active March 12, 2017 22:54
Partial class, with overrrides for the various overloads of DbContext.SaveChanges, for getting the inner exceptions from a "DbEntityValidationException" event. Change "DataModel" to the name you gave your data model.
public partial class DataModel
{
public override int SaveChanges()
{
try
{
return base.SaveChanges();
}
catch (DbEntityValidationException ex)
{
@tiesont
tiesont / so-secondary-nav-labels.css
Created September 17, 2017 02:16
Stack Overflow Add Labels to Secondary Nav
@-moz-document domain("stackoverflow.com") {
.so-header .secondary-nav .js-inbox-button,
.so-header .secondary-nav .js-achievements-button,
.so-header .secondary-nav .js-review-button,
.so-header .secondary-nav .js-site-switcher-button
{
display: block;
text-align: center;
}
@tiesont
tiesont / index-with-amd.html
Created May 30, 2018 01:25 — forked from bernos/index-with-amd.html
A javascript module template which supports an AMD loader (like requirejs) when available, but fails over to adding the module to a specified root context when an AMD loader is not available.
<!doctype html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<script data-main="main-with-amd" src="requirejs-1.0.4.min.js"></script>
</body>
</html>
@tiesont
tiesont / VisualStudioSolutionSLNstyler.xml
Created July 3, 2018 22:48 — forked from CADbloke/VisualStudioSolutionSLNstyler.xml
Notepad++ Syntax Highlighting for visual Studio .sln Solution files. Exported from NP++ 6.3.2To use, save this gist as an XML file, NP++ Language menu ==> Define your Language ==> click Import in the window that just popped up...then change the colo(u)rs in the pop-up window dialogues to something that offends you less.
<NotepadPlus>
<UserLang name="SLN" ext="sln" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03 04 00# 01 02</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@tiesont
tiesont / bootstrap-switch.scss
Last active August 12, 2018 23:21
Bootstrap Switch (https://www.abeautifulsite.net/bootstrap-4-switches) with calc() replaced by calculated values - using 14px as base font size. This allows the styles to work with IE9+ (which has a rendering bug related to flex and calc()).
//
// Switches for Bootstrap 4.
// https://www.abeautifulsite.net/bootstrap-4-switches
//
// - Fully customizable with Sass variables
// - No JavaScript required
// - Fully accessible
//
// IMPORTANT: These Sass variables are defined in Bootstrap's variables.scss. You should import that file first, then remove these.