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 CampaignOfferIspReportDatatable < AjaxDatatablesRails::Base | |
def sortable_columns | |
# Declare strings in this format: ModelName.column_name | |
@sortable_columns ||= [ | |
'Offer.name', | |
'Campaign.name', | |
'Carrier.name', | |
'visits', | |
'clicks', | |
'conversions', |
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
Campaign | |
has_many :campaign_offers | |
CampaignOffer | |
has_many :campaign_offer_reports | |
belongs_to :campaign | |
CampaignOfferReport | |
belongs_to :campaign_offer |
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 blacklisted_publishers | |
@campaigns = Campaign.joins(:campaign_publishers).where(:campaign_publishers => {blacklisted: true, blacklisted_on_publisher_network: false}).group(:campaign_id) | |
end | |
def manipulate_blacklisted_publishers | |
@campaigns = Campaign.joins(:campaign_publishers).where(:campaign_publishers => {blacklisted: true, blacklisted_on_publisher_network: false}).group(:campaign_id) | |
if params[:publisher_network_id].present? | |
@publisher_network = PublisherNetwork.find(params[:publisher_network_id]) | |
@campaigns = @campaigns.where(publisher_network_id: @publisher_network.id) | |
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 'httparty' | |
require 'json' | |
class VoluumApiV2 | |
include HTTParty | |
def urlify_time(time) | |
time.strftime("%Y-%m-%dT%H") << "%3A00%3A00Z" | |
end | |
def urlify_date(time) |
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
<%= f.collection_check_boxes(:ip_range_ids, @ip_ranges, :id, :isp) do |b| %> | |
<div class="row"> | |
<%= b.label(class: "check_box") do %> | |
<div class="col-xs-4"> | |
<%= b.check_box(class: "check_box") %> | |
</div> | |
<div class="col-xs-8"> | |
<%= b.object.isp %> | |
</div> |
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 API | |
include HTTParty | |
def initialize(options = {}) | |
@auth = { | |
:username => options[:username], | |
:password => options[:password] | |
} | |
@token = options[:token] | |
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 'rubygems' | |
require 'httparty' | |
require 'curb' | |
require 'net/http' | |
require 'benchmark' | |
include Benchmark | |
RUNS = 1000 | |
url = 'http://localhost:4567/' |
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 initialize(username, password) | |
auth = {:username => username, :password => password} | |
begin | |
begin | |
response = HTTParty.get("https://security.example.com/login", :basic_auth => auth) | |
case response.code | |
when 200 | |
puts "All good!" | |
data = JSON.parse(response.body) | |
@token = token = JSON.parse(response.body)['token'] |
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 Authenticable | |
# Devise methods overwrites | |
def current_user | |
@current_user ||= User.find_by(auth_token: request.headers['Authorization']) | |
end | |
def authenticate_with_token! | |
render json: { errors: "Not authenticated" }, status: :unauthorized unless user_signed_in? | |
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
$ rails c | |
Loading development environment (Rails 4.1.6) | |
2.1.4 :001 > User.create(email: "stefan@gmail.com", password: "somepassword123", password_confirmation: "somepassword123") | |
(0.2ms) begin transaction | |
User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."auth_token" = '' LIMIT 1 | |
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'stefan@gmail.com' LIMIT 1 | |
(0.1ms) rollback transaction | |
=> #<User id: nil, email: "stefan@gmail.com", encrypted_password: "$2a$10$l6LMCC4/LbAZQUxQBZK04O9ks3WXswUNfzhAQpMwBGe...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil, auth_token: ""> | |
2.1.4 :002 > |