Skip to content

Instantly share code, notes, and snippets.

View tiesont's full-sized avatar

Tieson Trowbridge tiesont

View GitHub Profile
@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 / 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-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 / 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 / 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace dotnet_aes
{
public class OpenSslAes
{
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 / gmailsender.cs
Last active January 2, 2016 08:59
Helper class used to access a Gmail account remotely for the purpose of sending an email message
/// <summary>
/// GmailSender: Class used to access a Gmail account remotely for the purpose of sending an email message
/// </summary>
public class GmailSender
{
/// <summary>
/// Static method. Accepts required elements for sending a email through the Google Mail system.
/// </summary>
/// <param name="to">The target (recipient) of the email message.</param>
/// <param name="subject">Subject line value for the email.</param>
@tiesont
tiesont / CustomMembershipProvider.cs
Last active December 22, 2015 04:49
Template implementation of a custom ASP.NET MembershipProvider, using C#.
using System;
using System.Collections.Specialized;
using System.Configuration.Provider;
using System.Web.Configuration;
using System.Web.Security;
namespace Custom.Providers
{
public class CustomMembershipProvider : MembershipProvider
{
@tiesont
tiesont / CustomRoleProvider.cs
Created September 3, 2013 05:32
Template implementation of a custom ASP.NET RoleProvider, using C#
using System;
using System.Collections.Specialized;
using System.Configuration.Provider;
using System.Linq;
using System.Web.Configuration;
using System.Web.Security;
namespace Custom.Providers
{
public class CustomRoleProvider : RoleProvider