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 merchant | def merchant_serp | |
# Test merchant to exercise "skip" # Test merchant to exercise "skip" | |
if params[:id].to_i == -1 if params[:id].to_i == -1 | |
merchant = Merchant.new(:name => "Skip this merchant", merchant = Merchant.new(:name => "Skip this merchant", | |
json_hash = ActiveSupport::JSON.decode(merchant.to_json json_hash = ActiveSupport::JSON.decode(merchant.to_json | |
purchase_link = scoped_url(:shopping) purchase_link = scoped_url(:shopping) | |
skip_this = true skip_this = true | |
earning_cashback = false earning_cashback = false | |
coupons_count = 0 coupons_count = 0 | |
coupons = [] coupons = [] |
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
cf = CloudFiles::Connection.new(CarrierwWave::Uploader::Base.cloud_files_username, CarrierWave::Uploader::Base.cloud_files_api_key) | |
cf.containers.map do |container_name| | |
container = cf.container(container_name) | |
{ | |
name: container_name, | |
metadata: container.meta_data, | |
cdn_metadata: container.cdn_metadata | |
} | |
end |
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 as_json | |
{attribute: 'value'} | |
end | |
def to_json | |
ActiveSupport::json.encode(as_json) | |
end |
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
json.id listing.id | |
json.referral_code listing.referral_code | |
json.directory_name listing.directory_name | |
json.description strip_tags(listing.description) | |
json.type listing.type.name.capitalize | |
json.premium listing.premium | |
json.tagline listing.tagline | |
json.website_url listing.website_url | |
json.review_count listing.licensee_reviews.count | |
json.average_rating listing.average_rating |
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
class MyController | |
include UnicodeHelpers | |
def action | |
unicode_htmlentities("string") | |
end | |
end |
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 zip_and_pgp_csv | |
tempfile = Tempfile.new('csv') | |
Zip::ZipOutputStream.open(tempfile.path) do |zip_file| | |
zip_file.put_next_entry(filename) | |
zip_file.print @csv_data | |
end | |
@csv_zip_data = tempfile.read | |
@csv_data = `echo '#{@csv_zip_data}' | gpg --batch -e -a -r "mknoll@adminisource.net"` | |
end |
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 zip_and_pgp_csv | |
tempfile = Tempfile.new('csv') | |
Zip::ZipOutputStream.open(tempfile.path) do |zip_file| | |
zip_file.put_next_entry(filename) | |
zip_file.print @csv_data | |
end | |
@csv_zip_data = tempfile.read | |
Open3.popen3('gpg --batch -e -a -r "mknoll@adminisource.net"') do |stdin, stdout, stderr| |
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 get_domain(domain_name) | |
json = Rails.cache.fetch("domain_#{domain_name}", :raw => true) do | |
domain = Domain.find_by_name(domain_name) | |
domain.to_json if domain | |
end | |
Domain.new.from_json(json) if json | |
end |
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
gateway = government.gateway.constanize.new(government.gateway.login, government.gateway.password, government.gateway.test_mode?) | |
if gateway.respond_to?(:store) | |
profile_id = gateway.store(credit_card) | |
gateway.purchase(amount, profile_id) | |
else | |
gateway.purchase(amount, credit_card) | |
end |
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
class String | |
alias old_to_date to_date | |
def to_date | |
if self =~ /(\d{1,2}).(\d{1,2}).(\d{4})/ | |
"#{$3.to_i}-#{$1.to_i}-#{$2.to_i}".old_to_date | |
else | |
old_to_date | |
end | |
end |