Skip to content

Instantly share code, notes, and snippets.

View JimBobSquarePants's full-sized avatar
💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)

James Jackson-South JimBobSquarePants

💭
(•_•) ( •_•)>⌐■-■ (⌐■_■)
View GitHub Profile
<div class="intro-copy">
<h2>"I am supposed to be a quote but I have the wrong markup."</h2>
<p class="user-desc">Cassie <span>Science Teacher</span></p>
</div>
#master-header .contact-number, #master-header .cta-links a, #mobile-nav .mobile-tools .contact-number, #mobile-nav .second-level a, #mobile-nav .top-level a, #primary-nav ul.top-level .primary-link, #quote-panel .btn-change, #quote-panel .btn-join-now, #quote-panel .value, .a-feature p, .accordion-content .header p, .btn-form-next, .btn-form-prev, .btn-get-quote, .btn-get-quote-white, .btn-join, .btn-large-primary, .btn-large-secondary, .btn-med-primary, .btn-med-secondary, .btn-members-services, .compare-cover-tile h1, .comparison-table .category-title p, .contact-us .tab-btns-row a, .contact-us h1, .contact-us h2, .contact-us h3, .extras-cover-table .key span, .extras-select .title, .form-section h1, .general-content h1, .general-content h2, .hero-image h1, .left-nav a, .legend h1, .live-quote-tool .bootstrap-select .dropdown-toggle .filter-option, .live-quote-tool .lqt-compare-table .column .group .group-label, .live-quote-tool .lqt-compare-table .column .product-label, .live-quote-tool .lqt-compare-table
@JimBobSquarePants
JimBobSquarePants / ColorOperator.cs
Created January 4, 2016 14:20
Generic operators
public static Color<T> operator +(Color<T> left, Color<T> right)
{
if (typeof(T) == typeof(byte))
{
return (Color<T>)(object)new Color<byte>(
(byte)((byte)(object)left.R + (byte)(object)right.R),
(byte)((byte)(object)left.G + (byte)(object)right.G),
(byte)((byte)(object)left.B + (byte)(object)right.B),
(byte)((byte)(object)left.A + (byte)(object)right.A));
}
@JimBobSquarePants
JimBobSquarePants / GetAllColorNames.cs
Created November 30, 2015 09:09
Gets all the System.Drawing names in the format I need.
void Main()
{
PropertyInfo[] colorProperties = typeof(Color).GetProperties(BindingFlags.Static | BindingFlags.Public);
List<Color> colors = colorProperties.Select(prop => (Color)prop.GetValue(null, null)).ToList();
Color rp = Color.FromName("RebeccaPurple");
colors.Add(rp);
foreach (Color c in colors.OrderBy(co => co.Name))
{
@JimBobSquarePants
JimBobSquarePants / ImageProcessorPreProcessor.cs
Created July 23, 2015 15:40
Demonstration code for Preprocessing uploaded images with Umbraco
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ImageProcessorPreProcessor.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Attaches ImageProcessor to the Media.Saving event to ensure that uploaded files do not exceed
// a maximum size.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
/// <summary>
/// Throttles duplicate requests.
/// Based loosely on <see href="http://stackoverflow.com/a/21011273/427899"/>
/// </summary>
public sealed class AsyncDuplicateLock
{
/// <summary>
/// The collection of semaphore slims.
/// </summary>
private static readonly ConcurrentDictionary<object, SemaphoreSlim> SemaphoreSlims
@JimBobSquarePants
JimBobSquarePants / button.html
Created June 10, 2015 21:48
This is a button?
<a href="#" class="button create-new-thread" data-controller="topic">
<div class="ink animate" style="height: 115px; width: 115px; top: -43.5px; left: 21px;"></div>
<i class="icon-Add"></i>
<span>Create new</span>
</a>
if (window.jQuery) {
(function ($, w, d) {
var $d = $(d);
$d.ready(function () {
$d.on("click", "a[data-smooth-scroll]", function (event) {
var $this = $(this),
href = $this.attr("href");
if (href.indexOf("#") === 0) {
@JimBobSquarePants
JimBobSquarePants / EnumerableInvocations.cs
Last active August 29, 2015 14:17
Enabling invocation of Enumerable methods without knowing the type at compile time.
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
/// <summary>
@JimBobSquarePants
JimBobSquarePants / Descendents.cs
Created February 4, 2015 12:38
Possible performance improvement in descendents.
internal static IEnumerable<IPublishedContent> EnumerateDescendants(this IPublishedContent content, bool orSelf)
{
if (orSelf) yield return content;
Stack<IPublishedContent> nodes = new Stack<IPublishedContent>(new[] { content });
while (nodes.Any())
{
IPublishedContent node = nodes.Pop();
yield return node;