Skip to content

Instantly share code, notes, and snippets.

@gkop
gkop / gist:2340796
Created April 9, 2012 01:58
Regexes to upgrade to new FactoryGirl syntax
# NOTE if you want to do this outside a git repo, find . -type f can by substituted for git grep -l 'Factory'
# fix Factory.create and Factory()
$ git grep -l 'Factory' | xargs perl -pi -e 's/Factory(\.create)?\((\:)?(\w+)(, )?/FactoryGirl\.create\($2$3$4/g'
# fix Factory.build
$ git grep -l 'Factory' | xargs perl -pi -e 's/Factory\.build\((\:)?(\w+)(, )?/FactoryGirl\.build\($1$2$3/g'
# fix Factory.define
# NOTE after running this, at the very least you still have to wrap your definitions sets with a FactoryGirl.define do end block,
@rahearn
rahearn / auto_strip_text_attributes.rb
Created March 20, 2012 19:17
Adding functionality to every model in a system
# This file is in lib
module AutoStripTextAttributes
extend ActiveSupport::Concern
included do
text_columns = columns.collect do |c|
c.name.to_sym if c.type == :string || c.type == :text
end.compact
@gnarf
gnarf / jQuery.ajaxQueue.min.js
Created June 21, 2011 23:52
jQuery.ajaxQueue - A queue for ajax requests
/*
* jQuery.ajaxQueue - A queue for ajax requests
*
* (c) 2011 Corey Frang
* Dual licensed under the MIT and GPL licenses.
*
* Requires jQuery 1.5+
*/
(function(a){var b=a({});a.ajaxQueue=function(c){function g(b){d=a.ajax(c).done(e.resolve).fail(e.reject).then(b,b)}var d,e=a.Deferred(),f=e.promise();b.queue(g),f.abort=function(h){if(d)return d.abort(h);var i=b.queue(),j=a.inArray(g,i);j>-1&&i.splice(j,1),e.rejectWith(c.context||c,[f,h,""]);return f};return f}})(jQuery)
@albertoperdomo
albertoperdomo / xvfb
Created December 20, 2010 16:08
xvfb init script
DISPLAY=:99
XVFB=/usr/bin/Xvfb
XVFBARGS="$DISPLAY -ac -screen 0 1024x768x16"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
/sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;