Skip to content

Instantly share code, notes, and snippets.

View glompix's full-sized avatar
😺
I may be slow to respond.

Samantha Branham glompix

😺
I may be slow to respond.
View GitHub Profile
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@glompix
glompix / avgitemsize.aspx
Created August 26, 2015 18:54
Calculate average item size for a Sitecore database
<%@ Page language="c#" %>
<%@ Import Namespace="Sitecore.Data.Items" %>
<!DOCTYPE html>
<html>
<head>
<title>Cache Admin</title>
<link rel="shortcut icon" href="/sitecore/images/favicon.ico" />
<%
var db = Sitecore.Configuration.Factory.GetDatabase("master");
Func<Item[]> ReturnAllItems = () =>
@glompix
glompix / ItemExtensions.cs
Last active August 29, 2015 14:19
Fix cache clear on remote publish in Sitecore language fallback module
public static Item GetFallbackItem(this Item item)
{
Assert.IsNotNull(item, "item cannot be null");
var success = false;
int iterations = 0, maxIterations = 5;
while (iterations++ < maxIterations)
{
var fallbackLang = item.Language.GetFallbackLanguage(item.Database);
if (fallbackLang != null &&
@glompix
glompix / myplate-improvements.tamper.js
Last active August 29, 2015 14:03
UX improvements for LiveStrong.com's MyPlate.
// ==UserScript==
// @name MyPlate Improvements
// @namespace http://glompix.com/
// @version 0.1
// @description A small set of improvements for LiveStrong's MyPlate app.
// @match http://www.livestrong.com/myplate/dashboard/*
// @copyright 2014, Stuart Branham
// ==/UserScript==
@glompix
glompix / bootstrap-tab-order.js
Created August 15, 2013 22:47
Preserve tab order within Bootstrap tabbables.
/* tab-order.js
Preserve tab order within Bootstrap tabbables.
*/
(function ($) {
var _tabKeyCode = 9;
var _tabbableSelector = ':input:not([type="hidden"]),a[href]'; // Links can be tabbed to too!
function getTabbableElements($el) {
return $el.find(_tabbableSelector);
}
@glompix
glompix / bootstrap-combobox.js
Created March 28, 2013 20:55
Simple comboboxes (manually editable selects) for jQuery/Bootstrap. Quick and dirty.
jQuery.fn.editableSelect = function () {
var selects = $(this).filter('select');
selects.each(function () {
// Add an edit button to the select control, bootstrap style.
var select = $(this);
select.wrap('<div class="input-append" />');
var editButton = $('<button class="btn" type="button" title="Enter your own value"><i class="icon-edit"></i></button>');
select.parent().append(editButton);
editButton.click(function () {
@glompix
glompix / FuzzyStringComparer.cs
Last active December 15, 2015 00:39
String comparer pulled from http://www.catalysoft.com/articles/StrikeAMatch.html and converted to C#. Wrote many years ago for a job.
namespace Poop
{
public class FuzzyStringComparer
{
/// <summary>Computes lexical similarity of two strings, case insensitive.</summary>
/// <returns>Lexical similarity value in the range [0,1].</returns>
/// <remarks>http://www.catalysoft.com/articles/StrikeAMatch.html</remarks>
public static double CompareLexical(this string str1, string str2)
{
if (str1 == str2)