Skip to content

Instantly share code, notes, and snippets.

def verify_response(response, response_signature)
public_key_pem = File.read(Rails.root.join('config', 'gcash-public-key2.pem'))
public_key = OpenSSL::PKey::RSA.new(public_key_pem)
signature_dest = Base64.strict_decode64(response_signature)
public_key.verify(OpenSSL::Digest::SHA256.new, signature_dest, response.to_json)
end
payload = {
"Request": {
"Product": {
"PrimaryCategory": "6614",
"Attributes": {
"name": "api create product test sample",
"short_description": "This is a nice product",
"brand": "Remark",
"model": "asdf",
"kid_years": "Kids (6-10yrs)"
<%
adyen = Adyen::Client.new
adyen.env = :test
# for basic-auth based implementations
adyen.ws_user = ENV['ADYEN_MERCHANT_LOGIN']
adyen.ws_password = ENV['ADYEN_MERCHANT_PASSWORD']
response = adyen.checkout.payment_methods({
amount: {
@alecguintu
alecguintu / gist:fdb8445294f0dada8c50
Last active August 29, 2015 14:20
Showing and hiding child components
Sample 1
_click: function() {
if ($('#add-here').is(':empty'))
React.render(<Child />, $('#add-here')[0]);
else
React.unmountComponentAtNode($('#add-here')[0]);
},
render: function() {
return(
<div>
class Shelf < ActiveRecord::Base
has_many :comics
has_many :books#, validate: -> {self.shelf_of == 'book'}
accepts_nested_attributes_for :comics
accepts_nested_attributes_for :books
# has a dropdown on view for shelf_of that could either be 'comic' or 'book
validates :shelf_of, inclusion: { within: %w(comic book) }
end
@alecguintu
alecguintu / snippet_areYouSure.js
Created September 4, 2014 10:18
Adding page:before-change for turbolinks
if (!settings.silent && !window.aysUnloadSet) {
window.aysUnloadSet = true;
$(window).bind('beforeunload', function() {
$dirtyForms = $("form").filter('.' + settings.dirtyClass);
if ($dirtyForms.length == 0) {
return;
}
// Prevent multiple prompts - seen on Chrome and IE
if (navigator.userAgent.toLowerCase().match(/msie|chrome/)) {
if (window.aysHasPrompted) {
@alecguintu
alecguintu / pickMultiple_store_remove.js.coffee
Last active August 29, 2015 14:05
Filepicker pickMultiple -> store -> remove
filepicker.pickMultiple picker_options, (pick_fpfiles) ->
for pick_fpfile, i in pick_fpfiles
sanitized_filename = sanitize_filename(pick_fpfile.filename)
console.log 'Sending file...'
console.log pick_fpfile
filepicker.store pick_fpfile, store_options, (store_fpfile) ->
console.log 'Callback of file...'
console.log pick_fpfile
@alecguintu
alecguintu / pickMultiple_store_remove.js.coffee
Last active August 29, 2015 14:05
Filepicker pickMultiple -> store -> remove
filepicker.pickMultiple picker_options, (pick_fpfiles) ->
for pick_fpfile, i in pick_fpfiles
sanitized_filename = sanitize_filename(pick_fpfile.filename)
filepicker.store pick_fpfile, store_options, (store_fpfile) ->
# Remove files from both fp.io and our root s3 path
# Here's where the problem happens. pick_fpfile is always the last from the list of pick_fpfiles since filepicker.store is asynchronous and pick_fpfile has already changed by the time the filepicker.remove's success callback has returned
filepicker.remove pick_fpfile, {policy: security.policy, signature: security.signature}
@alecguintu
alecguintu / pick_store_remove.js.coffee
Created September 2, 2014 10:40
Filepicker pick -> store -> remove
filepicker.pick picker_options, (pick_fpfile) ->
sanitized_filename = sanitize_filename(pick_fpfile.filename)
filepicker.store pick_fpfile, store_options, (store_fpfile) ->
# Remove files from both fp.io and our root s3 path
filepicker.remove pick_fpfile, {policy: security.policy, signature: security.signature}
$('ul.links').on 'ajax:success', '.link', (evt, data, status, xhr) ->
console.log 'link clicked'
console.log $(this)
$('#this-form').bind 'ajax:success', (evt, data, status, xhr) ->
console.log 'form submitted'
# # When .link is clicked
# link clicked
# [a.link ...]