Skip to content

Instantly share code, notes, and snippets.

View danheberden's full-sized avatar

Dan Heberden danheberden

View GitHub Profile
@danheberden
danheberden / Quewery 1.0
Created April 1, 2011 17:35
A selector engine
var Quewery = function( selector ) {
if( selector.match(/#[^\s]+$/) ) {
return [ document.getElementById( selector.substring(1) ) ];
} else {
return document.querySelectorAll( selector );
}
}
/*
* .serializeObject (c) Dan Heberden
* danheberden.com
*
* Gives you a pretty object for your form bizniss
*/
(function($){
$.fn.serializeObject = function( trimKey ) {
if ( !this.length ) { return false; }
// We override the animation for all of these color styles
jQuery.each("backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color outlineColor".split(" "), function(i,attr){
jQuery.fx.step[attr] = function(fx){
if ( !fx.colorInit ) {
fx.start = getColor( fx.elem, attr );
fx.end = getRGB( fx.end );
fx.colorInit = true;
}
var rgb = [];
@danheberden
danheberden / 4 Digit Time
Created March 6, 2011 01:15
Gets 4 digit time (hhmm) with optional time frame flooring (e.g. 0317 => 0315 )
/*
* Returns a 4 digit string of the time in hhmm format
* timeFrame will floor to the nearest multiple, e.g.
* fourDigitTime( 15, '', 2, 44 ); // returns "0230"
* hr and min will use the current time if not specified
* sep ( the separator between the hours and minutes ) defaults
* to an empty string ('')
*
* (c) Dan Heberden - danheberden.com
* https://gist.github.com/856911
@danheberden
danheberden / gyazo.php
Created February 17, 2011 06:20 — forked from cowboy/gyazo.php
<?PHP
/*
* PHP upload for Gyazo - v1.2 - 02/16/2011
* http://benalman.com/news/2009/10/gyazo-on-your-own-server/
*
* Copyright (c) 2009 "Cowboy" Ben Alman
* Licensed under the MIT license
* http://benalman.com/about/license/
*/
@danheberden
danheberden / Window vs Body scrolling
Created January 13, 2011 16:32
Find what the hell to scroll
var $docEl = $( document.documentElement ),
$body = $( document.body ),
// if docEl has a scrollTop, well, that kinda answers our question
$scrollable = $docEl.scrollTop() ? $docEL :
$body.scrollTop( $body.scrollTop() + 1 ).scrollTop() ? $body : $docEl;
// its like we can already tell!
if ( windowST ) {
$scrollable = $docEl;