Skip to content

Instantly share code, notes, and snippets.

View tiesont's full-sized avatar

Tieson Trowbridge tiesont

View GitHub Profile
@carlin-q-scott
carlin-q-scott / unobtrustive-validation-extensions.js
Last active November 12, 2022 02:51
ASP.NET Unobtrusive Validation for Bootstrap 5
(function ($) {
// Make ASP's unobtrusive validation compatible with Bootstrap 5 styling. See this for more details: https://stackoverflow.com/a/19006517/576153
$.validator.setDefaults({
errorElement: "span",
errorClass: "invalid-feedback",
highlight: function (element, errorClass, validClass) {
// Only validation controls
if (!$(element).hasClass('novalidation')) {
$(element).closest('.form-control').removeClass('is-valid').addClass('is-invalid');
}
@ygrenier
ygrenier / ControllerExtensions.cs
Last active October 25, 2019 20:32
ASP.NET Core - Controller extension to test if a view exists
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Mvc
{
/// <summary>
/// Controller extensions
/// </summary>
public static class ControllerExtensions
{
@arniebradfo
arniebradfo / any.component.html
Last active May 16, 2023 18:05
Angular *ngFor recursive list tree template
<h1>Angular 2 Recursive List</h1>
<ul>
<ng-template #recursiveList let-list>
<li *ngFor="let item of list">
{{item.title}}
<ul *ngIf="item.children.length > 0">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container>
</ul>
</li>
</ng-template>
@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
@DanDiplo
DanDiplo / JS-LINQ.js
Last active April 29, 2024 10:30
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
@maartenba
maartenba / DomainTemplateRoute - GetVirtualPath
Last active May 15, 2023 07:30
ASP.NET MVC 6 / ASP.NET 5 Domain Routing + Tenant Middleware
public string GetVirtualPath(VirtualPathContext context)
{
foreach (var matcherParameter in _matcher.Template.Parameters)
{
context.Values.Remove(matcherParameter.Name); // make sure none of the domain-placeholders are appended as query string parameters
}
return _innerRoute.GetVirtualPath(context);
}
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 46.7%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#428bca",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
@trailmax
trailmax / web.Release.config
Created February 22, 2014 22:33
Securing your cookies and STS header in web.config transformation
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<httpCookies httpOnlyCookies="true" requireSSL="true" lockItem="true" xdt:Transform="Replace" />
<authentication mode="Forms">
<forms loginUrl="~/Logon/LogOn" timeout="2880" requireSSL="true" xdt:Transform="Replace"/>
</authentication>
</system.web>
<?php
/**
* Database Connection class.
*
* Example:
* $dbi = DBConnection::getInstance();
* $q = "SELECT * FROM Users WHERE Username=?";
* $a = array($_GET['username']);
* $users = $dbi->query($q, $a);