Skip to content

Instantly share code, notes, and snippets.

View oomlaut's full-sized avatar

Paul Gueller oomlaut

  • Milwaukee, WI
View GitHub Profile
@oomlaut
oomlaut / parseQuerystring.jquery.js
Created July 23, 2011 15:14
Parse the querystring with jQuery, returning an object containing index/value pairs
jQuery.extend({
parseQuerystring: function(){
var nvpair = {};
var qs = window.location.search.replace('?', '');
var pairs = qs.split('&');
$.each(pairs, function(i, v){
var pair = v.split('=');
nvpair[pair[0]] = pair[1];
});
return nvpair;
@oomlaut
oomlaut / Markup.html
Created August 9, 2012 03:04
Basic Accordion UI Element
<dl class="accordion">
<dt>Accordion Heading 1</dt>
<dd>
<p>Some content</p></dd>
<dt>Accordion Heading 2</dt>
<dd>
<p>Some more content</p></dd>
<dt>Accordion Heading 3</dt>
<dd>
<p>Some final content</p></dd>
@oomlaut
oomlaut / BasicTabContent.jQuery.js
Created August 11, 2012 04:38
Basic Tabbed Content UI Element
if (typeof jQuery != "undefined") {
(function($) {
$('.accordion dt').each(function() {
$(this).on('click', function(){
$(this).toggleClass('on').siblings('.on').removeClass('on').end()
.next('dd').slideToggle().siblings('dd').slideUp();
}).next('dd').hide();
});
})(jQuery);
}​
@oomlaut
oomlaut / jQuery.textSummary.js
Created August 17, 2012 16:51
Text Summary jQuery Plug-in
$.fn.textSummary = function (options, callback) {
var settings = {
maxlength: 150,
morechar: "&hellip;"
};
$.extend(true, settings, options);
return this.each(function () {
var $context = $(this).hide().append($('<a>', {
@oomlaut
oomlaut / batters.php
Created May 10, 2013 16:28
Example of screen-scraping in PHP
<?
//include('dbconfig.inc.php');
//include('db.class.php');
//include('simplehtmldom/simple_html_dom.php');
$availableTeams = array("ARI","ATL","BAL","BOS","CIN","CHC","CHW","CLE","COL","DET","FLA","HOU","KCR","LAA","LAD","MIL","MIN","NYM","NYY","OAK","PHI","PIT","SD","SF","SEA","STL","TB","TEX","TOR","WSN");
foreach($availableTeams as $availableTeam)
{?>
<a href='batters.php?team=<?=$availableTeam?>'><?=$availableTeam?></a> |
<?}?>
@oomlaut
oomlaut / jquery.push-slider.js
Created May 10, 2013 16:30
Push slider (rejected work for client UI)
(function ($) {
/**
*
*/
$.fn.pushSlider = function (options, callback) {
var settings = {
initialSlide: 0,
duration: 840
};
$.extend(true, settings, options);
@oomlaut
oomlaut / listcolumnize.jquery.js
Created May 10, 2013 16:31
Columnize a list using jQuery
(function($){
$('ul').each(function() {
var $lis = $('li', this);
cols = [],
colNum= 4,
colLength = Math.ceil($lis.length / colNum),
$newList = $('#columnify');
for(var i = 0; i < colLength; i++){
cols.push($('<ul>').appendTo($newList));
}
@oomlaut
oomlaut / string_compare_validate.js
Created May 10, 2013 16:57
Using jQuery.validate, compare the values of input fields against one another, create notifications based on similarity rules
$.validator.addMethod("similarity", function(value, element, params){
var acceptable = .25;
function mush(str){
str = str.replace(/[ \?|\.|!|\(|\)|\\|\/]/g, '').toLowerCase();
var arr = [];
for(var i = 0; i <= str.length - 1; i++){
arr.push(str[i]);
}
return arr.sort();
@oomlaut
oomlaut / lorem.html
Created May 10, 2013 17:02
Sample markup for use with Site Style Guide
<h1>heading <code>&lt;h1&gt;</code></h1>
<h2>heading <code>&lt;h2&gt;</code></h2>
<h3>heading <code>&lt;h3&gt;</code></h3>
<h4>heading <code>&lt;h4&gt;</code></h4>
<h5>heading <code>&lt;h5&gt;</code></h5>
<h6>heading <code>&lt;h6&gt;</code></h6>
<hr />
<p>The <a href="#">a element </a> example <code>&lt;a href=&quot;#&quot;&gt;</code><br />
The <abbr title="Title text">abbr element</abbr> example <code>&lt;abbr title=&quot;&quot;&gt;</code><br />
The <b>b element</b> example <code>&lt;b&gt;</code><br />
@oomlaut
oomlaut / speedtest.php
Created May 24, 2013 01:07
PHP speed tests `json_encode` vs `serialize`
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
// Make a bit, honkin test array
// You may need to adjust this depth to avoid memory limit errors
$testArray = fillArray( 0, 5 );
// Time json encoding