Skip to content

Instantly share code, notes, and snippets.

View pcg79's full-sized avatar

Pat George pcg79

  • FreeAgent
  • Edinburgh, Scotland
View GitHub Profile
# Rails Template: something_great.rb
# by Jim Garvin (coderifous)
#
# * shoulda/mocha/factory girl
# * pacecar for lots of automatic scopes
# * haml
# * sprockets for javascript management
# * will paginate
# * limerick_rake gives some nice utilities
# * asks for a hoptoad API key, and if given, will setup hoptoad initializer
movie.rb:
# With help from
# http://almosteffortless.com/2008/12/11/easy-upload-via-url-with-paperclip/
has_attached_file :poster,
:styles => {
:small => "150x150>"
}
// An Unobtrusive Javascript (UJS) driver based on explicit behavior definitions. Just
// put a "data-behaviors" attribute on your view elements, and then assign callbacks
// for those named behaviors via Behaviors.add.
var Behaviors = {
observers: {},
observe: function(trigger) {
$(document.body).observe(trigger, this.onTrigger.bind(this));
},
@pcg79
pcg79 / set_cookie_domain.rb
Created November 10, 2010 22:29
Changes required by IE cookie bug
@pcg79
pcg79 / gist:738207
Created December 12, 2010 17:49
Using jQuery to manipulate Interstitial page
<script type="text/javascript">
$(document).ready(function() {
var href = $("#redirect_url")[0].href;
$("a#replace_me").attr("href", href);
$("a#replace_me").text(href);
$("#redirect_to").hide();
});
</script>
<p>Greetings. We are now redirecting you to the site that you requested.</p>
@pcg79
pcg79 / gist:738210
Created December 12, 2010 17:55
Raw HTML of Interstitial page
<p id="redirect_to">You will be redirected to the following URL in 5 seconds: <a id="redirect_url" href="<your link's url>"><Your link's url></a></p>
class Rating < ActiveRecord::Base
belongs_to :user
belongs_to :rater, :class_name => 'User', :foreign_key => 'rater_id'
belongs_to :account
attr_accessible :score, :rater_id, :user_id, :rater, :user
VALID_SCORES = 1..3
validates_presence_of :score, :user_id, :rater_id, :account_id
@pcg79
pcg79 / .autotest
Created July 20, 2011 15:11
.autotest for ignoring solr
Autotest.add_hook :initialize do |autotest|
%w{.git .svn .hg .DS_Store ._* vendor tmp log doc solr}.each do |exception|
autotest.add_exception(exception)
end
end
#!/usr/bin/env ruby
require 'bundler'
gems = ARGV
if gems.empty?
puts "Updating all gems"
Bundler.definition(true)