Skip to content

Instantly share code, notes, and snippets.

@bill-barron
bill-barron / Responsive SVG fix for IE
Last active February 11, 2016 04:35
IE9 - IE11 doesn't honor percent-based widths on the SVG element. To get around this, you need to nest SVG within two div elements and use the styles shown below. To control the width of the graphic, just adjust the width of the '.outer' element to suit you needs using whatever width units you like.
<style>
.inner { position: relative; padding-top: 100%; }
.inner svg {width: 100%; height: 100%; position: absolute; margin-top: -100%; left: 0; right: 0;}
</style>
<div class="outer" style="width: 50%;"><!-- This makes the graphic take up 50% of the page or whatever container '.outer' is in. -->
<div class="inner">
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
<g>
<path fill="rgb(175, 216, 248)" stroke="rgb(0, 0, 0)" stroke-width="1" d="M200,40 A160,160 0 0 1 313.1370849898476,313.1370849898476 A160,160 0 0 1 40,200.00000000000003 L200,200 Z">
@bill-barron
bill-barron / guid.py
Last active August 29, 2015 14:28
Replace the GUID of a Sitecore media item with that item's url -- Works in Notepad++ with the Python Script plugin installed. Converts 32-bit GUID like this {01234567-89AB-CDEF-0123-456789ABCDEF} into a url like this http://www.example.com/~/media/0123456789ABCDEF0123456789ABCDEF.ashx
editor.pyreplace(r"\{([0-9a-fA-F]{8})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{4})-([0-9a-fA-F]{12})\}", r"http://www.example.com/~/media/\1\2\3\4\5.ashx")
Windows Registry Editor Version 5.00
; Based on instructions from http://www.php.net//manual/en/configuration.file.php
; This registry entry tells php where to find the php.ini file.
; The default location is c:\\Windows
; You can specify a different ini location for each version of PHP
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
; You store they key in this folder [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\{version}] where {version} = 5.5.12 in this case
; The Key is "IniFilePath"
; The Value is the path to the folder containing the ini file for the given php version
; No trailing \\ is necessary
@bill-barron
bill-barron / TransferData.cs
Last active August 29, 2015 14:02
Helper class for reading multiple fields of data from Sitecore items. Also for transferring multiple fields of data between items with different field names
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using Sitecore;
using Sitecore.Configuration;
using Sitecore.Collections;
using Sitecore.Data;
using Sitecore.Data.Fields;
@bill-barron
bill-barron / loadThen.js
Last active April 3, 2019 09:27
An alternative to jQuery's ajax load() function that has the same interface except it does not take a callback function, bit instead it returns a promise.
(function ($) {
var _loadThen = $.fn.loadThen;
/**
* An alternative to jQuery's ajax load() function that has the same interface
* except it does not take a callback function, but instead it returns a promise.
* The promise will be resolved when the content are loaded into the set of matched elements.
* @param url {string} A string containing the URL to which the request is sent.
* @param params {object or string} A plain object or string that is sent to the server with the request.
* @returns {jQuery Promise} with params (html, status, jqXHR).
@bill-barron
bill-barron / remove.js
Last active April 3, 2019 09:26
Remove elements and unload scripts from the page without jQuery. Works with IE8+. See: http://caniuse.com/#feat=queryselector for compatability. You can use this script like so: remove(selector) or remove([selector, selector, selector, ...]) or remove(element) or remove('script, style');
(function (scope) {
var remove = function (selector) {
if(selector instanceof Element && selector.parentElement)
selector.parentElement.removeChild(selector);
if(typeof selector === "string" && document.querySelectorAll) {
var list = document.querySelectorAll(selector)
for(var i = 0; i < list.length; i += 1)
remove(list[i]);
}
};
@bill-barron
bill-barron / Modernizr.Analytics.js
Last active December 14, 2015 01:39
Modernizr-Analytics
/***************************************************************************
* FeatureLogger - Saves features detected by Modernizr to google analytics
***************************************************************************/
(function () {
var _gaq = _gaq || [],
Modernizr = Modernizr || {};
for(testName in Modernizr) // For every Modernizr test
if(typeof Modernizr[testName] === 'boolean') // If it is a boolean
_gaq.push(['_trackEvent', 'modernizr', testName, ((Modernizr[testName]) ? 'Yes' : 'No')]); // Log a yes or no
})();