This file contains 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 RedditService | |
def self.post_report(report, token) | |
client = OAuth2::AccessToken.new(oauth_client, token) | |
url = "http://www.civbounty.com" | |
perp = Perpetrator.find(report.perpetrator_id) | |
user = User.find(report.user_id) | |
title = "Bounty of #{report.bounty}d placed on #{perp.name} CivBounty" | |
opts = { kind: 'link', url: url, title: title, sr: 'Rook'} | |
reddit_response = client.post("/api/submit", opts) |
This file contains 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
ActiveRecord::Schema.define(:version => 20130117202104) do | |
create_table "civilizations", :force => true do |t| | |
t.string "name" | |
t.datetime "created_at", :null => false | |
t.datetime "updated_at", :null => false | |
end | |
create_table "claims", :force => true do |t| | |
t.integer "hunter_id" |
This file contains 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 Perpetrator < ActiveRecord::Base | |
attr_accessible :name | |
has_many :reports | |
scope :sort_by_highest_bounty, order("max_bounty DESC") | |
scope :sort_by_most_reported, order("record_count DESC") | |
scope :sort_by_most_evidence, order("evidence_count DESC") | |
scope :filter_by_civ, lambda {|civ| where(["reports.civilization_id = ?", civ])} | |
scope :sort_by_most_wanted, order(" ( (SUM(CASE when reports.active = 't' THEN reports.bounty ELSE 0 END) - MAX(reports.bounty))*(COUNT(DISTINCT reports.id) + (SUM(COALESCE(evidence_links.evidence_count,0)) * 3 ) ) ) / (MIN(extract(epoch FROM now() - reports.created_at)) / 86400 + 1.3) DESC") |
This file contains 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 Bill < ActiveRecord::Base | |
attr_accessible :invoice, :amount, :initiated_by_id, :payer_id, :origin_id, :destination_id ,:accepted, :paid, :auto, :frequency, :payments_left | |
belongs_to :initiated_by, class_name: 'Member', foreign_key: :initiated_by_id | |
belongs_to :payer, class_name: 'Member', foreign_key: :payer_id | |
belongs_to :origin, class_name: 'Account', foreign_key: 'origin_id' | |
belongs_to :destination, class_name: 'Account', foreign_key: 'destination_id' | |
validates_numericality_of :amount, greater_than_or_equal_to: 0.01 | |
validates :amount, :presence => {message: "cannot be blank"} |
This file contains 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 Canoe | |
class CommitValue < Struct.new(:email, :committed_date); end | |
def self.weight(commit_values) | |
sorted_by_email_list = commit_values.group_by(&:email) | |
scored_by = sorted_by_email_list.each_with_object({}) do |(email, commit), hsh| | |
hsh[email] = sorted_by_email_list[email].count | |
hsh |
This file contains 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 Player | |
def play_turn(warrior) | |
@warrior = warrior | |
@direction ||= :backward | |
@health ||= warrior.health | |
@hurt ||= false | |
@step ||= true | |
explore(@direction) |
This file contains 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 FizzBuzz | |
def self.play(array) | |
array.collect do | num | | |
self.fizzbuzz(num) || self.buzz(num) || self.fizz(num) || num | |
end | |
end | |
def self.fizz(n) |
OlderNewer