Skip to content

Instantly share code, notes, and snippets.

@AntMooreWebDev
AntMooreWebDev / EnumHelper.GetAttributeOfType.cs
Created August 26, 2021 12:39
Gets an attribute on an enum field value
public static class EnumHelper
{
/// <summary>
/// Gets an attribute on an enum field value"/>
/// </summary>
/// <typeparam name="T">The type of the attribute you want to retrieve</typeparam>
/// <param name="enumVal">The enum value</param>
/// <returns>The attribute of type T that exists on the enum value</returns>
/// <example><![CDATA[string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;]]></example>
/// <see href="https://stackoverflow.com/a/9276348/3990156"/>
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event) {
// On-page links
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
&&
@AntMooreWebDev
AntMooreWebDev / redirect-rule-by-ip.config
Created March 10, 2021 13:50
How to add a redirect rule that is ignored if accessed from a specific IP
<rule name="[Rule name]" stopProcessing="true">
<match url="[URL to match]" ignoreCase="false" />
<conditions>
<add input="{REMOTE_HOST}" pattern="^[ip.\address]" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="[Target URL]" />
</rule>
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) [id]
,[contentNodeId]
,[versionId]
,[propertytypeid]
,[dataInt]
,[dataDecimal]
,[dataDate]
,[dataNvarchar]
,[dataNtext]
@AntMooreWebDev
AntMooreWebDev / .htaccess maintenance redirect
Created January 26, 2021 11:41
A small rewrite rule to send all users to maintenance page (except some excluded IP)
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^11\.22\.33\.44$ [NC] # Can add multiple lines here for different IPs
RewriteCond %{REQUEST_URI} !^/maintenance.html$ [NC]
RewriteRule ^(.*)$ "/maintenance.html" [R=302,L]

Umbraco Table Descriptions

Information pertaining to the tables created when UmbracoCMS is installed

cmsMemberType

Stores information relating to Member properties.

<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
@AntMooreWebDev
AntMooreWebDev / slugify.js
Last active May 21, 2019 09:16 — forked from mathewbyrne/slugify.js
Javascript Slugify
function Slugify(string) {
const a = 'àáäâãåèéëêìíïîòóöôùúüûñçßÿœæŕśńṕẃǵǹḿǘẍźḧ·/_,:;'
const b = 'aaaaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
.replace(/\-\-+/g, '-') // Replace multiple - with single -
@AntMooreWebDev
AntMooreWebDev / comma-snippet.js
Last active May 11, 2019 14:05 — forked from ashcdev/comma-snippet.js
Convert Checkboxes or Similar into Comma Separated list
var checkedVals = $('input[type=checkbox]:checked').map(function() {
return this.value;
}).get().join(",");
$(*TARGET*).val(checkedVals);