Skip to content

Instantly share code, notes, and snippets.

html * {
color-profile: sRGB;
rendering-intent: auto;
}
.cm-s-solarized-light {
background-color: #fdf6e3;
color: #657b83;
}
.cm-s-solarized-light .emphasis {
font-weight: bold;
@rmurphey
rmurphey / gist:3086328
Created July 10, 2012 21:23
What's wrong with Netmag's "Optimize your JavaScript" post

What's wrong with Netmag's "Optimize your JavaScript" post

Update: The original post on Netmag has been updated since this was written.

I tweeted earlier that this should be retracted. Generally, these performance-related articles are essentially little more than linkbait -- there are perhaps an infinite number of things you should do to improve a page's performance before worrying about the purported perf hit of multiplication vs. division -- but this post went further than most in this genre: it offered patently inaccurate and misleading advice.

Here are a few examples, assembled by some people who actually know what they're talking about (largely Rick Waldron and Ben Alman, with some help from myself and several others from the place that shall be unnamed).

Things that are just plain wrong

$.fn.myPlugin = function(args) {
// set defaults for the plugin
var defaults = {
foo : 'bar'
},
// override those defaults with user-provided args
settings = $.extend(defaults, args),
// define functions for stuff you'll do a lot
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@rmurphey
rmurphey / gist:846908
Created February 28, 2011 03:47
examples of testing with jasmine
function multiply(a, b) {
return a * b;
}
function divide(a, b) {
if (b === 0) {
throw "Don't try to divide by zero!";
}
return Math.round(a / b);
@rmurphey
rmurphey / gist:3105199
Created July 13, 2012 14:30 — forked from paulirish/gist:3098860
Open Conference Expectations

Open Conference Expectations

This document lays out some baseline expectations between conference speakers and conference presenters. It was prepared by three experienced conference speakers -- one of whom has also organized conferences -- and influenced by many others. Its goal is to let speakers know what they might reasonably expect from a conference, in exchange for the hours we expect them to spend researching, preparing, and rehearsing, and the time they will spend away from home and family.

We believe that all speakers should reasonably expect these things, not just speakers who are known to draw large crowds, because no one is a rockstar but more people should have the chance to be one. We believe that conferences are better -- and, dare we say, more diverse -- when the people speaking are not just the people who can afford to get themselves there, either because their company paid or they foot the bill themselves.

These expectations should serve as *a starting point for discussion between sp

@rmurphey
rmurphey / repo.txt
Created December 15, 2011 00:27
mulberry repo & scaffold reorg proposal
- lib
- cli (nee mulberry)
- js (nee toura_app)
--- vendor
--- mulberry
----- _Capability.js
----- _Component.js
----- Page.js (nee toura_app/pageControllers/Configurable.js)
----- base.js
----- base.css

What do you think the following code does?

function fn(msg, time) {
  setTimeout(function() {
    console.log(msg);
  }, time);
}

fn('it works', 1000);
#!/bin/sh
# retab a list of files from 2 spaces to 4 spaces
# todo: read the list of files from a file
for i in \
client/scripts/components/describe.jsx \
client/scripts/components/includes/header.jsx \
client/scripts/components/index.jsx \
client/scripts/components/layouts/default.jsx \
jQuery.namespaces : {
myNamespace : '/js/myNamespace/'
};
// this module would be in a separate file at /js/myNamepsace/MyModule.js
$.provide('myNamespace.MyModule');
jQuery.module('myNamespace.MyModule', null, {
defaults : {
hello : 'goodbye',