Skip to content

Instantly share code, notes, and snippets.

@rtekie
rtekie / api_sample.rb
Created April 9, 2012 20:37
LoyaltyPlus API call sample
require 'digest' # Not needed if you are using rails.
require 'cgi' # Not needed if you are using rails.
secret_key = "SECRET_KEY" # Your secret
params = { :email => "CUSTOMER_EMAIL", :uuid => "ACCOUNT_ID" } # Your api call parameters
string_to_hash = params.sort{|x,y| x[0].to_s <=> y[0].to_s}.reduce(secret_key){|x,y| x + y.to_s} # Concatenate in alphabetical order of parameter name, prepend with secret_key
params[:sig] = Digest::MD5.hexdigest(string_to_hash) # Compute hash
api_url = "http://loyalty.500friends.com/api/enroll.gif?" + params.map{|x,y| "#{x}=#{CGI::escape(y)}"}.join("&") # Construct the url.
api_url # should be the url of the api call
@rtekie
rtekie / share_product.js
Created April 10, 2012 00:37
LoyaltyPlus share a product
<script type="text/javascript" charset="utf-8">
try{
var ffImageUrl = "IMAGE URL GOES HERE";
var ffProductName = "PRODUCT NAME GOES HERE";
var ffProductDescription = "PRODUCT DESCRIPTION GOES HERE";
var ffMessage = "This is my style: " + ffProductName + " on YOUR WEBSITE GOES HERE";
}catch(ex){
}
</script>
<script type="text/javascript">_ffLoyalty.displayWidget(YOUR_WIDGET_ID, {message: ffMessage, url: document.location.href, image_url: ffImageUrl, title : ffProductName, description : ffProductDescription)});</script>
@rtekie
rtekie / share_deal.js
Created April 10, 2012 00:38
LoyaltyPlus share a deal
<script type="text/javascript" charset="utf-8">
try{
var ffImageUrl = "IMAGE URL GOES HERE";
var ffDealName = "DEAL NAME GOES HERE";
var ffDealDescription = "DEAL DESCRIPTION GOES HERE";
var ffMessage = "I found this great deal on YOUR WEBSITE GOES HERE: " + ffDealName ;
}catch(ex){
}
</script>
<script type="text/javascript">_ffLoyalty.displayWidget(YOUR_WIDGET_ID, {message: ffMessage, url: document.location.href, image_url: ffImageUrl, title : ffDealName, description : ffDealDescription)});</script>
@rtekie
rtekie / program_page.js
Created April 10, 2012 17:16
LoyaltyPlus Program Page script
<script src="https://d3aa0ztdn3oibi.cloudfront.net/javascripts/ff.loyalty.widget.js" type="text/javascript"></script>
<iframe id="ff_member_iframe" style="width:760px; height:1045px; border:0" frameBorder="0"></iframe>
<script type='text/javascript'>
_ffLoyalty.initialize( "ACCOUNT_ID" );
_ffLoyalty.loadIframe({ 'page' : 'program_overview' });
</script>
@rtekie
rtekie / subdomains.rb
Created May 14, 2012 13:14
Support for Rspec / Capybara subdomain integration testing
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
#
# Sample subdomain test:
# it "should test subdomain" do
# switch_to_subdomain("mysubdomain")
# visit root_path
# end
DEFAULT_HOST = "lvh.me"
@rtekie
rtekie / releases.rake
Created July 26, 2012 16:58
Releases rake file skeleton
namespace "x.x.x.x" do
desc "bar"
task :foo => [:environment] do
# foo implementation goes here
end
end
namespace "y.y.y.y" do
@rtekie
rtekie / bv500.html
Created August 7, 2012 20:37
LoyaltyPlus Bazaarvoice JavaScript integration
<script src="https://d3aa0ztdn3oibi.cloudfront.net/javascripts/ff.loyalty.widget.js" type="text/javascript">
<script type="text/javascript">
_ffLoyalty.initialize("YOUR_ACCOUNT_ID");
$BV.ui("submission_container", {
onEvent: function(json){
if (json.pageType = "Preview") {
_ffLoyalty.setUserEmail();
}
if (json.pageStatus == "REVIEW_THANKYOU" && json.eventSource == "Display") {
@rtekie
rtekie / cronsentry_notify.php
Created August 26, 2012 03:27
PHP example of using API to notify CronSentry upon a job completion
<?php
// PHP example of using API to notify CronSentry upon a job completion
// For API documentation please go to http://www.cronsentry.com/help#api
// set POST variables
$url = 'http://api.cronsentry.com/api/v1/notifications';
$parameters = array(
'api_key' => 'YOUR_API_KEY',
'job_name' => urlencode('Your job name'),
'status' => 1,
@rtekie
rtekie / cronsentry_notify.py
Created August 26, 2012 03:29
Python example of using API to notify CronSentry upon a job completion
# Python example of using API to notify CronSentry upon a job completion
# For API documentation please go to http://www.cronsentry.com/help#api
import urllib
import requests
# set POST variables
url = 'http://api.cronsentry.com/api/v1/notifications'
parameters = {
'api_key' : 'YOUR_API_KEY',
@rtekie
rtekie / cronsentry_notify.rb
Created August 26, 2012 03:29
Ruby example of using API to notify CronSentry upon a job completion
# Ruby example of using API to notify CronSentry upon a job completion
# For API documentation please go to http://www.cronsentry.com/help#api
require 'open-uri'
require 'rest_client'
# set POST variables
url = 'http://api.cronsentry.com/api/v1/notifications'
api_key = 'YOUR_API_KEY'
job_name = URI::encode('Your job name')