Skip to content

Instantly share code, notes, and snippets.

@zachleat
zachleat / jquery.scrolly.js
Created April 5, 2011 19:52
jQuery scrolly special event
/*
* Changes by Zach Leatherman (@zachleat)
* from James Padolsey Special Scroll Events
* http://james.padolsey.com/javascript/special-scroll-events-for-jquery/
* -------------------------------------------------------
* Dual licensed under the MIT and GPL licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/copyleft/gpl.html
*/
@zachleat
zachleat / gist:980895
Created May 19, 2011 14:41
HTML5 Boilerplate Issue #378 (No Compatibility View button, tested in IE7/IE8/IE9)
<!--[if IE ]><![endif]-->
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@zachleat
zachleat / gist:2008932
Created March 9, 2012 21:56
Prevent zoom on focus
// * iOS zooms on form element focus. This script prevents that behavior.
// * <meta name="viewport" content="width=device-width,initial-scale=1">
// If you dynamically add a maximum-scale where no default exists,
// the value persists on the page even after removed from viewport.content.
// So if no maximum-scale is set, adds maximum-scale=10 on blur.
// If maximum-scale is set, reuses that original value.
// * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0">
// second maximum-scale declaration will take precedence.
// * Will respect original maximum-scale, if set.
// * Works with int or float scale values.
@zachleat
zachleat / gist:4695349
Last active December 12, 2015 01:59
Talk abstract for Nebraska Code Camp 2013: Tool or Die (A Web Developer's Workflow)
“Tool and die makers are a class of machinists who work primarily in
toolroom environments—…often in an environment with flexible, semipermeable
boundaries from production work.”
These are the people that make the tools to make the products. This was the
environment I grew up in—watching my father work as a tool and die maker.
He could make anything! But more importantly, he knew the value of good
tools—even if you had to construct them yourself.
Tools are important and tooling for Web Development is improving! I'll go
@zachleat
zachleat / gist:5101237
Last active December 14, 2015 14:29
Speaker Backlog for NebraskaJS
@zachleat
zachleat / jquery.postmessage.js
Created April 10, 2013 14:21
postMessage polyfill for IE < 8 that uses window.name and queues messages so they aren't lost while polling. Requires a JSON.parse polyfill (like JSON.js).
/*!
* jQuery postMessage - v1.0 - 8/26/2011
*
* Copyright (c) 2011 "zachleat" Zach Leatherman
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://jquery.org/license
*/
/* Forked from http://benalman.com/projects/jquery-postmessage-plugin/
@zachleat
zachleat / gist:5405752
Created April 17, 2013 16:34
Modernizr/modernizr.com Issue #31
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
*/
;
window.Modernizr = (function( window, document, undefined ) {
var version = '2.6.2',
@zachleat
zachleat / gist:5407068
Last active December 16, 2015 08:39
Differences between Pure Internet Explorers and IE Compatibility Modes

Or, yet more evidence that you should use feature detection instead of browser/user agent sniffing.

IE9

Not supported in IE9 but works in IE10-as-IE9

  • Unprefixed CSS transform. Should require -ms-transform but doesn’t require it.

IE8

@zachleat
zachleat / reading_time.rb
Last active October 21, 2020 23:00
Read this in X minutes Liquid Filter Plugin (for Jekyll)
# Outputs the reading time
# Read this in “about 4 minutes”
# Put into your _plugins dir in your Jekyll site
# Usage: Read this in about {{ page.content | reading_time }}
module ReadingTimeFilter
def reading_time( input )
words_per_minute = 180
@zachleat
zachleat / gist:6114627
Created July 30, 2013 16:39
position: sticky Notes

Supported (does not work on table headers):

  • Chrome Canary 30 (behind about:flags “experimental Web Platform features”)
  • Chrome 28 (behind about:flags “experimental WebKit features”)

Supported (works on table headers):

  • iOS 6.1

Not Supported:

  • iOS 5.1
  • Firefox 22 (Mac)