Skip to content

Instantly share code, notes, and snippets.

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source .bash_profile
rvm install 1.9.2
rvm gemset create r3
rvm use 1.9.2@r3 --default
@rromanchuk
rromanchuk / gist:979707
Created May 18, 2011 22:13
Refunding paypal xpress checkout
Paypal.sandbox!
r = Paypal::NVP::Request.new(:username => PAYPAL[:username], :password => PAYPAL[:password], :signature => PAYPAL[:signature])
r.request('RefundTransaction', {'TRANSACTIONID' => '2VV74337KH776410C', 'REFUNDTYPE' => 'Full'})
@rromanchuk
rromanchuk / gist:967646
Created May 11, 2011 23:48
decoding signed request for canvas facebook app or page
def parse_signed_request(request)
# Facebook's signed requests come in two parts -- the signature and the data payload
# see http://developers.facebook.com/docs/authentication/canvas
return {} if request.blank?
encoded_sig, payload = request.split(".")
sig = base64_url_decode(encoded_sig)
# if the signature matches, return the data, decoded and parsed as JSON
if OpenSSL::HMAC.digest("sha256", FB[:secret_key], payload) == sig