Skip to content

Instantly share code, notes, and snippets.

View jethrolarson's full-sized avatar
:shipit:

Jethro Larson jethrolarson

:shipit:
  • Tableau
  • Seattle
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>#jq140 template</title>
</head>
<body>
<h1>#jq140 template and rules</h1>
<ul>
<li>Submission must fit in a tweet, including '#jq140'. That's 134 characters of js.</li>
/*
Many beginning jQuery people forget to save the results of a selection and
just call $('foo') over and over. The only time you would need to do that is if the
DOM changes. Otherwise you can just save the results somewhere when the
selection is first made. Much more performant.
Here's a mini jQuery plugin that just caches the results of a selector after
the first time it's invoked.
*/
<!DOCTYPE html>
<html>
<head>
<title>Is this where web development is going?</title>
<script src="style.css.js"></script>
<script src="jquery.js"></script>
<script src="underscore.js"></script>
<script src="backbone.js"></script>
<script src="mustache.js"></script>
<script src="ICanHaz.js"></script>
@jethrolarson
jethrolarson / gist:1030087
Created June 16, 2011 19:49
isMouseWithin.js
(function($){
window.util ={mousepos:{}};
//Constantly tracks mouse position
$(document).bind('mousemove.util', function(e){
//adapted from http://www.quirksmode.org/js/events_properties.html
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
util.mousepos.left = e.pageX;
util.mousepos.top = e.pageY;
}
@jethrolarson
jethrolarson / _grid.scss
Last active September 27, 2015 07:37
Super simple compass grid system for modern browsers (IE8+)
/*
F'n Sweet Grid system
Reduced fluid version of http://960.gs with fixed-width gutters
No support for < IE8
Basic usage:
In some stylesheet:
@include grid();
In your html:
<div class="container">
<div class="grid_4">4</div>
@jethrolarson
jethrolarson / grid.css
Created September 22, 2011 04:14
Super simple compass grid system for modern browsers (IE8+)
.container{overflow:hidden;zoom:1;margin:0;padding:0}
.container > *{float:left;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;padding-left:10px}
.container > .alpha,.container > :first-child{padding-left:0!important}
.container > .grid_12{padding:0}
.grid_1{width:8.333%}
.grid_2{width:16.667%}
.grid_3{width:25%}
.grid_4{width:33.333%}
.grid_5{width:41.667%}
.grid_6{width:50%}
//You can use jQuery deferreds as well as traditional callbacks
$.fn.wait = function (ms,callback){
var dfd = $.Deferred();
setTimeout(function(){
dfd.resolve();
},ms);
if(callback){
dfd.done(callback);
}
return dfd.promise();
@jethrolarson
jethrolarson / _.template.js
Created January 19, 2012 00:56
Mod of _.template binds `this` to the element passed in, and adds <%@varname%> as a handy shortcut to <%=this.varname%>
//OVERWRITING Underscore.js's templates
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_.templateSettings = {
evaluate : /<%([\s\S]+?)%>/g,
interpolate : /<%=([\s\S]+?)%>/g,
escape : /<%-([\s\S]+?)%>/g
value : /<%@([\s\S]+?)%>/g // inserts value of a variable on the object or "" if undefined
});
var $w = $(window);
function imageHolder() {
//Organize our thumbs
var iThumb = 1, firstImage;
$('#album-thumbs > ul > li').each(function() {
if(iThumb === 1) {
$(this).addClass('current');
// Adds Support for localStorage to IE5-IE7 using userData
// <http://msdn.microsoft.com/en-us/library/ms531424(VS.85).aspx>
// See also <http://caniuse.com/#feat=namevalue-storage>
if(typeof window.localStorage === 'undefined') (function () {
var userdataKey = 'localStorage',
userdata = document.createElement('b');
userdata.style.display = 'none';
userdata.style.behavior = 'url("#default#userData")';