Skip to content

Instantly share code, notes, and snippets.

View bkeepers's full-sized avatar

Brandon Keepers bkeepers

View GitHub Profile
@bkeepers
bkeepers / party.rb
Created December 1, 2010 05:35 — forked from dpetersen/party.rb
module Kernel
def the(a, b)
a.new(b)
end
def roof
Exception
end
def yo!
// jQuery.fn.or
//
// $('.dont-exist').or('.does-exist') //=> [.does-exist];
// $('.does-exist').or('.dont-exist') //=> [.does-exist];
$.fn.extend({
or: function(selector, context) {
if ($(this).length > 0) {
return $(this);
} else {
# Just drop this little diddy in your app to get some (not perfect) information on query times and such
# This will eventually become an official plugin but for those who can't wait, enjoy.
if defined?(NewRelic)
module MMNewRelicTracing
def self.included(model)
model.metaclass.class_eval do
add_method_tracer :find, 'Database/#{self.name}/find'
add_method_tracer :find!, 'Database/#{self.name}/find!'
add_method_tracer :paginate, 'Database/#{self.name}/paginate'
add_method_tracer :first, 'Database/#{self.name}/first'
// easy refresh-css keybinding to alt-w
// alt-r was taken in IE, so consider this a CSS Weefresh
// original code from http://paulirish.com/2008/how-to-iterate-quickly-when-debugging-css/
$(document).keyup(function(e){
if (e.which == 87 && e.altKey) {
$('link').each(function() {
if((/stylesheet/i).test(this.rel) && this.href) {
var href = this.href.replace(/(&|\?)forceReload=\d+/,'');
this.href = href + ((/\?/).test(href) ? '&' : '?' ) + 'forceReload=' + new Date;
@bkeepers
bkeepers / gist:132611
Created June 19, 2009 13:24 — forked from defunkt/gist:132456
open new shells in the most recently visited directory
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
cd
else