Original source: https://hackpad.com/Web-And-Mobile-Revenue-Models-(final)-EgXuEtSibE7
- Display Ads - ex. Yahoo!
- Search Ads - ex. Google
- Text Ads - ex. Google
- Video Ads - ex. Hulu
- Audio Ads - ex. Pandora
- Promoted Content - ex. Twitter, Tumblr
development: &global_settings | |
database: textual_development | |
host: 127.0.0.1 | |
port: 27017 | |
test: | |
database: textual_test | |
<<: *global_settings | |
production: |
# Set HONEYBADGER_FOO_BAR_JOB=asdf where asdf is the check in value Honeybadger gives you. | |
class ApplicationJob < ActiveJob::Base | |
after_perform { |job| job.honeybadger_checkin } | |
# Check in with Honeybadger to let us know that the job was performed | |
# if there is an identifier configured for the job. | |
def honeybadger_checkin | |
identifier = honeybadger_checkin_identifier | |
return unless identifier.present? |
-- https://www.postgresql.org/docs/current/fuzzystrmatch.html#id-1.11.7.26.7 | |
-- Calculates the distance between two strings. | |
SELECT levenshtein('New York', 'New York'); -- 0 | |
SELECT levenshtein('New York', 'New Jersey'); -- 5 | |
SELECT levenshtein('New York', 'Dallas'); -- 8 | |
-- find the opponent with the name closest to 'New York' | |
SELECT * FROM opponents WHERE team_id = 1 | |
ORDER BY levenshtein(name, 'New York') |
# https://www.postgresql.org/docs/13/ddl-partitioning.html#DDL-PARTITIONING-DECLARATIVE | |
class PartitionByDay | |
class Row | |
include Virtus.model | |
attribute :name, String | |
attribute :expression, String | |
end | |
def self.all(table) |
module BoxOutSports | |
def self.kv | |
@kv ||= KeyValueJsonb.new(use_local_time: Rails.env.test?) { | |
ActiveRecord::Base.connection | |
} | |
end | |
end |
require 'mongo_mapper' | |
require 'spec' | |
require 'log4r' | |
require 'versionomy' | |
# Logger used for logging MongoDB database commands | |
Log4r::Logger.new('TMP') | |
Log4r::Logger['TMP'].outputters = Log4r::StdoutOutputter.new(:console) | |
Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m") | |
Log4r::Logger['TMP'].level = Log4r::DEBUG |
diff --git a/Gemfile b/Gemfile | |
index e3a71e1..34ba75c 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -107,3 +107,4 @@ gem "pundit" | |
gem "rack-canonical-host" | |
gem "ruby-readability" | |
gem "rinku", require: "rails_rinku" | |
+gem "virtus" | |
diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb |
# Shorcut because typing GitHub everywhere gets old | |
SQL = GitHub::SQL | |
module GitHub | |
class SQL | |
private | |
# Overwrite interpolate to be ok with postgres casting (::regclass, etc.). | |
def interpolate(sql, extras = nil) | |
sql.gsub(/(:?):([a-z][a-z0-9_]*)/) do |match| |
Original source: https://hackpad.com/Web-And-Mobile-Revenue-Models-(final)-EgXuEtSibE7
module Harmony | |
# Allows accessing config variables from harmony.yml like so: | |
# Harmony[:domain] => harmonyapp.com | |
def self.[](key) | |
unless @config | |
raw_config = File.read(RAILS_ROOT + "/config/harmony.yml") | |
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys | |
end | |
@config[key] | |
end |