Skip to content

Instantly share code, notes, and snippets.

View joshuaclayton's full-sized avatar

Josh Clayton joshuaclayton

View GitHub Profile
@joshuaclayton
joshuaclayton / git-track
Created December 10, 2008 20:30 — forked from sstephenson/git-track
Auto-tracking of git branches
#!/bin/sh
branch=$(git branch 2>/dev/null | grep ^\*)
[ x$1 != x ] && tracking=$1 || tracking=${branch/* /}
git config branch.$tracking.remote origin
git config branch.$tracking.merge refs/heads/$tracking
echo "tracking origin/$tracking"
module WillPaginate
module ViewHelpers
def will_paginate_with_collection_check(*args)
# if args.first.respond_to?(:total_pages) doesn't work if using
# with a presenter, since the presenter probably uses method_missing to
# delegate method calls to the collection instance variable
if (args.first.total_pages rescue false)
will_paginate_without_collection_check(*args)
end
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
(function($) {
var binder = function(e, dataKey, dataValue) {
var $this = $(this),
oldValue = $this.data(dataKey),
newValue = dataValue,
passed = {
attr: dataKey,
from: oldValue,
to: newValue
};
// ==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(/-/, '');
// 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"))();
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); }),
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)
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
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