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
def recalculate(new_bid_price) | |
self.gros_revenue = installs_given * new_bid_price.to_f | |
self.net_revenue = self.gros_revenue * revenue_share.to_f | |
end |
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
require 'json' | |
require 'thread' | |
APP_ID = "f99f9a81-5687-4abf-842b-2f11a72af31e" | |
FIELDS = ["rec_id","sdk_version","platform","app_store","country","promo_type","campaign_id","type","user_id","giving_app_id","ad_id","receiving_app_id"] | |
def build_for(folder) | |
File.open("./#{folder}/report_data.json") do |file1| | |
File.open("report_#{folder}.csv", "w+") do |file2| |
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
Timeout::timeout(@timeout_in) do | |
info("Request: #{self.name}", URI.join(@host_url, url), body.to_json) | |
response = connection.post do |request| | |
request.url url | |
request.body = body.to_json | |
request.headers['Content-Type'] = 'application/json' | |
end | |
info("Response: #{self.name}", "Recommendations for ad_request_id: #{body['ad_request_id']}", response.body) |
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
require 'spec_helper' | |
module RTB | |
module V1 | |
describe ExportJson do | |
subject { ExportJson.new } | |
let(:good_campaigns) { [build(:campaign, enabled: true), build(:campaign, enabled: false)] } |
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
admin.factory 'BaseCollection', ['uuid4', '$rootScope', '$timeout', (uuid, $rootScope, $timeout) -> | |
class EventEmitter | |
constructor: (@base, @_subscriptions = {}) -> | |
@publicMethods = | |
on: @on | |
emit: (type, model) => | |
$rootScope.$emit(@eventKey(model, type), model) | |
on: (type, callback) => |
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
def transform_postback(source, transformation_map) | |
result = {} | |
transformation_map.each_pair do |k,v| | |
path = case k | |
when Symbol then k.to_s | |
when String then k.split('.') | |
end | |
val = case v | |
when Symbol then source[v] if source.has_key?(v) |
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
module Promotions | |
class AutoOptimizeMix < BaseMix | |
# Now we are supporting only 1 ad in the template. | |
def select | |
self_ad = self_ads.first(1) # => returns Array because of using passed param to first method. | |
paid_ad = paid_ads.first(1) # => returns Array because of using passed param to first method. | |
return paid_ad if self_ad.empty? | |
return self_ad if paid_ad.empty? |
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
def assign_session_campaigns(ads) | |
ads.each do |ad| | |
ad.session_app = active_campaigns.session_apps[ad.app_id] | |
# @note we should see only campaign.allowed_ad_ids here. | |
session_campaigns = active_campaigns.session_campaigns[ad.app_id] | |
session_campaigns.allowed_for!(ad) | |
ad.session_campaigns = session_campaigns | |
end |
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 RedshiftAdapter | |
include SimpleConf | |
def self.config_file_name | |
'database' | |
end | |
def initialize | |
@connection = PG::Connection.new(:host => self.host, | |
:port => self.port, |
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
nmap -p T:80 ip |