Skip to content

Instantly share code, notes, and snippets.

@polimorfico
polimorfico / quaderno-charges-for-braintree.html
Last active July 18, 2016 11:54
Create a Braintree charge with Quaderno.js
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quaderno.js for One-Off Charges on Braintree</title>
<!-- jQuery is used only for this example; it isn't required to use Stripe -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- The required libs -->
@polimorfico
polimorfico / quaderno-charges-for-paypal.html
Last active August 29, 2015 14:22
Create a PayPal charge with Quaderno.js
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quaderno.js for One-Off Charge on PayPal</title>
<!-- jQuery is used only for this example; it isn't required to use Quaderno -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- The required Quaderno lib -->
@polimorfico
polimorfico / quaderno-subscriptions-for-paypal.html
Last active August 29, 2015 14:22
Create a PayPal subscriptions with Quaderno.js
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quaderno.js for PayPal Subscriptions</title>
<!-- jQuery is used only for this example; it isn't required to use Quaderno -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- The required Quaderno lib -->
@polimorfico
polimorfico / quaderno-subscriptions-for-braintree.html
Last active August 29, 2015 14:22
Create a Braintree Subscription with Quaderno.js
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quaderno.js for Braintree Subscriptions</title>
<!-- jQuery is used only for this example; it isn't required to use Quaderno -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- The required libs -->
@polimorfico
polimorfico / quaderno-charges-for-stripe.html
Last active June 19, 2017 10:11
Create a Stripe charge with Quaderno.js
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quaderno.js for One-off Charges on Stripe</title>
<!-- The required libs -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript" src="https://js.quaderno.io/v2/"></script>
@polimorfico
polimorfico / quaderno-subscriptions-for-stripe.html
Last active January 30, 2018 17:37
Create a Stripe subscription with Quaderno.js
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quaderno.js for Stripe Subscriptions</title>
<!-- jQuery is used only for this example; it isn't required to use Quaderno -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- The required libs -->
@polimorfico
polimorfico / gist:4074902
Created November 14, 2012 21:18
Force your params encoding in Rails

If you have problems with your params encodings, use a Rack middleware to encode them before rails params parsing code is executed.

First, build a class according to the signature of a rack middleware layer.

#lib/force_params_encoding.rb
class ForceParamsEncoding
  def initialize(app)
    @app = app
  end
@polimorfico
polimorfico / spanish_tax_id_validator.rb
Created May 28, 2012 21:24
Spanish Tax ID Validator
class SpanishTaxIdValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
valid_tax_id = case
when value.match(/^[0-9]{8}[a-z]/i)
validate_nif(value.dup)
when value.match(/[a-w][0-9]{7}[0-9a-z]/i)
validate_cif(value.dup)
when value.match(/[xyz][0-9]{7,8}[a-z]/i)
validate_nie(value.dup)
else