This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
var dirtyForm = { | |
settings: { | |
changedClassName: "changed", | |
checkableSelector: ":radio, :checkbox", | |
eventName: "change.dirty_form", | |
eventBubbling: { | |
preventDefault: function(){ return false; }, | |
stopPropagation: function(){ return false; }, | |
bubbles: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'test/unit/ui/console/testrunner' | |
# cute. | |
module Color | |
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 } | |
def self.method_missing(color_name, *args) | |
color(color_name) + args.first + color(:clear) | |
end | |
def self.color(color) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope = LoggedException | |
scope = scope.search(params[:query]) unless params[:query].blank? | |
scope = scope.days_old(params[:date_ranges_filter]) unless params[:date_ranges_filter].blank? | |
scope = scope.by_exception_class(params[:exception_names_filter]) unless params[:exception_names_filter].blank? | |
scope = scope.by_controller_and_action(*params[:controller_actions_filter].split('/').collect(&:downcase)) unless params[:controller_actions_filter].blank? | |
scope = scope.sorted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base.send :include, AASM | |
base.aasm_column :status | |
base.aasm_initial_state :drafted | |
base.aasm_state :drafted | |
base.aasm_state :submitted | |
base.aasm_state :booked | |
base.aasm_state :lost | |
base.aasm_state :cancelled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit ed20f4dcc656ac55adbe9515466ef19d102e9ead | |
Author: Pratik Naik <[email protected]> | |
Date: Thu Mar 5 22:45:04 2009 +0000 | |
should_be_fucking_restful | |
diff --git a/lib/shoulda/action_controller.rb b/lib/shoulda/action_controller.rb | |
index 4719851..3723c72 100644 | |
--- a/lib/shoulda/action_controller.rb | |
+++ b/lib/shoulda/action_controller.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Base | |
def self.nullify(*args) | |
callback = args.shift if ActiveRecord::Callbacks::CALLBACKS.include?(args.first) | |
self.send(callback || "before_validation", lambda {|model| args.each {|a| model.send("#{a}=", nil) if model.send(a).blank? }}) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Webrat.configure do |config| | |
config.mode = :selenium | |
end | |
class Cucumber::Rails::World | |
def wait_for_ajax(timeout = 15000) | |
selenium.wait_for_condition "window.Ajax.activeRequestCount == 0", timeout | |
end | |
def wait_for_effects(timeout = 15000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniq: function() { | |
var resultArray = this.clone().sort(function(a,b) { if(a == b || JSON.stringify(a) == JSON.stringify(b)) { return 0; } if(a > b || JSON.stringify(a) > JSON.stringify(b)) { return 1; } return -1; }), | |
clone = this.clone(), | |
first = 0, | |
last = resultArray.length, | |
sorted = arguments[0] || false; | |
var unsort = function(sortedArray) { | |
var result = []; | |
var parsedSortedArray = $.map(sortedArray, function(i) { return JSON.stringify(i); }), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With Rails remote form helpers, the AJAX call is bound on the onsubmit attribute. | |
// Submitting that form via a framework (Prototype, jQuery, etc.) doesn't use the onsubmit | |
// attribute's Javascript because it was never explicitly bound. Is this really the only | |
// way to have a framework trigger the code nestled within the onsubmit attr? | |
$(document).ready(function() { | |
$("form").each(function() { | |
var self = $(this); | |
self.submit(function() { | |
new Function(self.attr("onsubmit"))(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name JIRA Issue Dock Badge | |
// @namespace http://fluidapp.com | |
// @description Displays JIRA Issue within dock badge | |
// @author Josh Clayton | |
// ==/UserScript== | |
(function () { | |
if (window.fluid) { | |
window.fluid.dockBadge = window.document.title.match(/\[.(\w{3,4}\-\d+)]/)[1].replace(/-/, ''); |