Moved to a proper Git repository.
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).
If you're interested in learning more in person, VanJS (@vanjs) often has node-related content.
And like Rob and Brock mentioned in the session, they're starting up the Vancouver Node Brigade (@NodeBrigade) for a more node-focused meetup.
Now, as promised, links from the session and some expanded notes. All questions, comments, and pull requests are most welcome.
| // use this in a bookmarklet to make a button for this script: | |
| // javascript:document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).setAttribute('src','https://raw.github.com/gist/2379456/sum_hours.js') | |
| (function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| window.atom = atom = {} | |
| atom.input = { | |
| _bindings: {} | |
| _down: {} | |
| _pressed: {} | |
| _released: [] | |
| bind: (key, action) -> | |
| @_bindings[key] = action |
| # Heres how I've been working with arbitrary backbone events: | |
| # | |
| # Obviously in Backbone you can use events elsewhere as well, for | |
| # more info see the docs here: http://documentcloud.github.com/backbone/ | |
| # useful for running this with node.. else browser this with the right includes. | |
| # includes | |
| if typeof window is 'undefined' | |
| # npm install -g backbone | |
| # gives you: |
| # https://www.varnish-cache.org/docs/2.1/tutorial/vcl.html | |
| # https://www.varnish-cache.org/trac/wiki/VCLExamples | |
| # Summary | |
| # 1. Varnish will poll the backend at /health_check to make sure it is | |
| # healthy. If the backend goes down, varnish will server stale content | |
| # from the cache for up to 1 hour. | |
| # 2. Varnish will pass X-Forwarded-For headers through to the backend | |
| # 3. Varnish will remove cookies from urls that match static content file | |
| # extensions (jpg, gif, ...) |
| points_per_hour<-2000 | |
| layd_raw_transition<- | |
| data.frame(timestamp=factor(c(rep(seq(0,11),points_per_hour), | |
| rep(seq(12,23),points_per_hour))), | |
| latency=c(rgamma(12*points_per_hour,shape=3,scale=60), | |
| rgamma(12*points_per_hour*0.9,shape=2,scale=60), | |
| rgamma(12*points_per_hour*0.1,shape=8,scale=60)), | |
| type=(c(rep("before",12*points_per_hour), | |
| rep("after",12*points_per_hour)))) |
| # HAProxy config | |
| mkdir /etc/haproxy | |
| cat > /etc/haproxy/haproxy.cfg << EOF | |
| global | |
| maxconn 4096 | |
| defaults | |
| mode http | |