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
| # Note: under the shared directory, have a config subdir with the database.yml file in it. | |
| default_run_options[:pty] = true | |
| set :application, "" | |
| set :deploy_to, "/var/www/apps/#{application}" | |
| set :scm, :git | |
| set :repository, "git@github.com:railsrumble/#{application}.git" | |
| set :branch, "master" | |
| set :deploy_via, :remote_cache |
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
| Settings.voting_begin = Time.now.to_s | |
| Competition.setup! | |
| def doit(iterations = 10) | |
| total_time = 0.0 | |
| count = 0 | |
| iterations.times do | |
| entry = Entry.find(:first, :order => 'RAND()') | |
| user = User.find(:first, :order => 'RAND()') | |
| user.can_rate(entry) | |
| ratings = { |
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
| ?> Rating.count | |
| => 80371 | |
| >> r = Rating.find(26) | |
| => #<Rating id: 26, value: 3, user_id: 1089, rateable_id: 46, rateable_type: "Entry", created_at: "2008-10-23 01:51:38", updated_at: "2008-10-23 01:51:38", category: "completeness", certified: true> | |
| >> r.save | |
| => true | |
| >> r = Rating.find(26) | |
| ActiveRecord::RecordNotFound: Couldn't find Rating with ID=26 | |
| from /usr/local/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1379:in `find_one' | |
| from /usr/local/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1362:in `find_from_ids' |
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
| >> users = User.all | |
| << snip >> | |
| >> def trim_percentage(users, cutoff) | |
| >> above, below, novote = 0, 0, 0 | |
| >> users.each do |user| | |
| ?> avg = user.ratings.average(:value).to_f | |
| >> if avg < 1 | |
| >> novote += 1 | |
| >> elsif avg < cutoff | |
| >> below += 1 |
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
| >> e = Entry.find(:first, :conditions => {:name => 'MyConf'}) | |
| => #<Entry id: 137, name: "MyConf", .... | |
| >> e.ratings.average(:value) | |
| => 2.469 | |
| >> e.ratings.certified.average(:value) | |
| => 2.6507 | |
| >> e.rating(:as_float => true) | |
| => 2.6507 | |
| >> e.rating(:certified => true, :as_float => true) | |
| => 2.469 |
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
| def rating(*args) | |
| options = args.extract_options! | |
| category = options.delete(:category) | |
| as_float = options.delete(:as_float) | |
| certified = options.delete(:certified) | |
| user_or_ip = options.delete(:user) || options.delete(:ip) | |
| if user_or_ip && Rating.instance_methods.include?('user') | |
| options[:conditions] = ["user_id = ?", user_or_ip.id] | |
| elsif user_or_ip |
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 RubyGems by default. | |
| require 'rubygems' | |
| # Require UtilityBelt for lots of functionality | |
| # http://utilitybelt.rubyforge.org/ | |
| require 'utility_belt' | |
| UtilityBelt::Equipper.equip(:defaults) | |
| UtilityBelt::Equipper.equip(:with, :string_to_proc, :pipe, :not, | |
| :language_greps, :is_an, :clipboard, | |
| :interactive_editor) |
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
| /* GitHub Commits, version 0.0.1 | |
| * (c) 2009 Jeff Rafter | |
| * | |
| * Based on GitHub Badge by Dr Nic Williams (but with the good code removed) | |
| * | |
| * You need: jquery.js, md5.js | |
| * | |
| * See http://pajhome.org.uk/crypt/md5 for more info. | |
| * | |
| *--------------------------------------------------------------------------*/ |
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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'fastercsv' | |
| require 'json' | |
| def jsonify(set) | |
| Dir.chdir set | |
| images = [] | |
| folders = Dir["*/"] | |
| folders.each do |folder| |
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
| define_index do | |
| indexes :name, :sortable => true | |
| indexes entry(:subdomain), :as => :entry_subdomain, :sortable => true | |
| indexes entry(:description), :as => :entry_description, :sortable => true | |
| indexes entry(:name), :as => :entry_name, :sortable => true | |
| indexes entry(:resources_used), :as => :entry_resources, :sortable => true | |
| has :state | |
| where "state IN ('approved', 'qualified', 'verified')" | |
| end |
OlderNewer