Skip to content

Instantly share code, notes, and snippets.

View jeremyckahn's full-sized avatar

Jeremy Kahn jeremyckahn

View GitHub Profile
@jeremyckahn
jeremyckahn / styleUtils.js
Created March 19, 2011 02:16
Some useful functions for working with CSS styles in JavaScript.
/**
* Checks to see if an element has a given inline style set on it.
* @param{HTMLElement} el The element to inspect
* @param{String} style The inline style you would like to know about
* @returns{Boolean|null|undefined} Returns `true` is the string is present, `false` if it is not, `null` if there are no inline styles set on `el`, and `undefined` if `style` is not a string.
*/
function hasInlineStyle (el, style) {
var inlineStyles = $(el).attr('style'),
i;
@jeremyckahn
jeremyckahn / propagateKapi.sh
Created March 21, 2011 01:54
I use this when pushing a stable release from dev.
git checkout master;
git merge dev;
git checkout gh-pages;
git merge dev;
git push origin dev;
git push origin master;
git push origin gh-pages;
git checkout dev;
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
$(function managerExample () {
// Declare private manager vars here
var container;
function init () {
// Select all of the DOM elements the manager uses in `init`
container = $('#container');
}
// Functions with a leading underscore imply that the function is not to be used publicly
@jeremyckahn
jeremyckahn / fytojs.js
Created March 26, 2011 22:56
Fuck yeah, totally overzealous JavaScript!
javascript:(function () {
var textTags = ['p', 'a', 'li', 'code', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'button', 'div', 'span', 'dt', 'dd'],
els,
i, j,
link;
link = document.createElement('link');
link.setAttribute('href', 'http://fonts.googleapis.com/css?family=Oswald');
link.setAttribute('rel', 'stylesheet');
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@jeremyckahn
jeremyckahn / getOuterHTML
Created April 19, 2011 15:27
Useful shim for getting the outerHTML text of a DOM node
// Useful shim for getting the outerHTML text of a DOM node. Requires jQuery.
function getOuterHTML (el) {
var ret, wrapper;
if (el.hasOwnProperty && el.hasOwnProperty('outerHTML')) {
ret = el.outerHTML;
} else {
wrapper = $('<div>').html(el);
ret = wrapper.html();
@jeremyckahn
jeremyckahn / gist:948381
Created April 29, 2011 14:30
seawolff kapi fix
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>kapi</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Jeremy Kahn">
<!-- Date: 2010-12-07 -->
@jeremyckahn
jeremyckahn / vsa_seq.js
Created May 6, 2011 15:20
vsa.sequence psuedocode
vsa.sequenceStart('box.move', function(sequenceName) {
box.animate({
'left': '+=200'
}, {
'duration': 500
}).animate({
'left': 0
}, {
'duration': 500,
'complete': function() {