Skip to content

Instantly share code, notes, and snippets.

View aarongustafson's full-sized avatar
👋
he/him/his

Aaron Gustafson aarongustafson

👋
he/him/his
View GitHub Profile
@aarongustafson
aarongustafson / first-pass.css
Last active August 29, 2015 14:17
Code examples for my Quantity Queries meet Flexbox post.
.listing--events {
display: flex;
flex-wrap: wrap;
}
.event {
box-sizing: border-box;
padding: 1.25rem; /* 20px padding */
margin: 0 0 1.25rem 0; /* 20px bottom margin */
flex: 0 0 100%;
@aarongustafson
aarongustafson / css-linking.html
Last active August 29, 2015 14:22
Bringing Sanity and Order to Device Testing
<link rel="stylesheet" href="default.css" media="all">
<link rel="stylesheet" href="advanced.css" media="only screen">
Verifying I am +aarongustafson on my passcard. https://onename.com/aarongustafson
eCSStender.register(
{'selector': 'p'},
'*',
function( selector, properties, media, specificity )
{
console.log('eCSStender matched the selector "' + selector +
'" in the media type ' + media + '. It’s properties follow:');
console.log(properties);
console.log('The specificity of this selector is ' + specificity);
}
<html>
<head>
<title>Circular references between JavaScript and DOM</title>
<script type="text/javascript">
// <![CDATA[
var obj;
window.onload = function()
{
obj = document.getElementById("DivElement");
document.getElementById("DivElement").expandoProperty = obj;
@aarongustafson
aarongustafson / dom-leak-fix.js
Created December 5, 2009 19:37
Example of a memory leak issue in IE and how to resolve it
window.onload = function()
{
var
body = document.getElementsByTagName('body')[0],
div = document.createElement('div'),
parentDiv, childDiv;
for ( i = 0; i < 5000; i++ )
{
parentDiv = div.cloneNode(true);
parentDiv.onclick = foo;
@aarongustafson
aarongustafson / directly-passed-regexp.js
Created December 6, 2009 00:40
Regexp performance is faster when you "precompile" (examples from JavaScript Performance Rocks!)
function directPassing ( string )
{
return string.match( /abc/ );
}
@aarongustafson
aarongustafson / constructors.js
Created December 6, 2009 00:44
Object and array literals are faster than constructors
function usingConstructors( string )
{
var a = new Array(), o = new Object();
}
function camelize( str )
{
var
HYPHEN = '-',
bits = str.split(HYPHEN),
length = bits.length,
i = 1,
new_str;
if ( length == 1 ) { return bits[0]; }
if ( str.charAt(0) == HYPHEN ) {
function camelize( str )
{
var
HYPHEN = '-',
bits = str.split(HYPHEN),
length = bits.length,
i = 1,
new_str;
if ( length == 1 ) { return bits[0]; }
if ( str.charAt(0) == HYPHEN ) {