Skip to content

Instantly share code, notes, and snippets.

def self.get_product(sku, params = {})
params.reverse_merge!({
'advertiser-ids' => 'joined',
'advertiser-sku' => sku,
'website-id' => COMMISSION_JUNCTION_PID
})
Nokogiri.XML(get('https://product-search.api.cj.com/v2/product-search?', params))
end
def redirect_for_geo_partner
return unless request.env['GEOIP_COUNTRY_CODE'] && geo_partner = Partner.find_by_country(request.env['GEOIP_COUNTRY_CODE'])
desired_path = request.path
if logged_in?
if on_partner_site?
if current_user.referable.nil? || (current_user.referable && !current_user.referable.kind_of?(Partner))
# This user has no partner but is on a partner site. Kick them back to app.
redirect_to "http://#{HOST}" + desired_path
# Apache sets an environment variable called USER_GEO on every request
# with a country code for where the IP is from
def redirect_for_geo_partners
return unless geo_partner = Partner.find_by_country(env['USER_GEO'])
# Store the request path
desired_path = request.path
if logged_in?
if on_partner_site?
def blah
begin
Timeout.timeout(1) do
sleep(2)
end
rescue Exception => e
return {:foo => :bar}
end
end
convert: function(amount, from, to) {
$.get("/currency_conversion/" + amount + "/from/" + from + "/to/" + to, function(response) {
parseFloat(response);
});
}
def self.send_update_to(user, date = ActivityUpdateMailer.current_or_next_update)
# blah blah
end
@moxie
moxie / gist:817701
Created February 9, 2011 01:27
Sample Gist
<style type="text/css">
body {
background: black;
}
</style>
a.button, button.button {
font-family: "Lucida Grande", Tahoma, Arial, sans-serif;
float: left;
margin: 0 7px 0 0;
padding: 0px;
background: transparent;
text-decoration: none;
border: none;
display: block;