Skip to content

Instantly share code, notes, and snippets.

@chrome
chrome / bm.js
Created May 24, 2011 04:20
jquery.role benchmark
$(function(){
var num = 100;
var test_count = 10000;
for(var i = 0; i < num; i++) {
$('body').append('<div class="c'+i+'" id="i'+i+'" role="r'+i+'" data-attr="a'+i+'">'+i+'</div>');
}
var randoms = [];
@chrome
chrome / jquery.role.js
Created May 23, 2011 07:30
jquery.role — sizzle edition ;)
jQuery.expr.match['ROLE'] = /\$((?:[\w\u00c0-\uFFFF\-]|\\.)+)/;
jQuery.expr.preFilter['ROLE'] = function( match, curLoop, inplace, result, not, isXML ) {
match = " " + match[1] + " ";
return match;
}
jQuery.expr.filter['ROLE'] = function( elem, match ) {
return (" " + elem.getAttribute('role') + " ").indexOf( match ) > -1;
}
class BudgetItemsController < InheritedResources::Base
load_and_authorize_resource
respond_to :html, :json
before_filter :get_statistics, :only => [:index]
layout 'application', :except => [:edit, :update, :create]
def index
@new_budget_item = BudgetItem.new
super