This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In controller | |
result = TaxCalculator.new(order).call | |
if result[:success] | |
render json: { value: result[:value] } | |
else | |
render json: { errors: result[:errors] }, status: 422 | |
end | |
# The service | |
class TaxCalculator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# app/controllers/application_controller.rb | |
# author: Boris Barroso | |
# email: boriscyber@gmail.com | |
class ApplicationController < ActionController::Base | |
layout lambda{ |c| | |
if (c.request.xhr? or params[:xhr]) | |
false | |
elsif params[:print].present? | |
"print" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Sign up</h2> | |
<div id="stripe_error" class="alert alert-error" style="display:none" > | |
</div> | |
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'card_form form-vertical' }) do |f| %> | |
<h3><%= params[:plan].titleize if params[:plan] %> Subscription Plan</h3> | |
<%= hidden_field_tag 'plan', params[:plan] %> | |
<%= f.error_notification %> | |
<%= f.input :f_name, :autofocus => true %> | |
<%= f.input :l_name %> | |
<%= f.input :email, :required => true %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Download the certificate with: | |
`wget -O config/rds-combined-ca-bundle.pem http://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem` | |
Then connect with: | |
`postgres://user:password@amazon-host/db_name?sslmode=require&sslrootcert=config/rds-combined-ca-bundle.pem` | |
References: | |
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.SSL | |
https://github.com/jeremyevans/sequel/issues/897 | |
http://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT | |
http://dba.stackexchange.com/questions/77811/how-to-connect-to-an-amazon-postgresql-database-using-ssl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Load Sinon.JS in the SpecRunner: | |
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script> | |
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script> | |
<script type="text/javascript" src="sinon-1.0.0.js"></script> | |
<script type="text/javascript" src="sinon-ie-1.0.0.js"></script> | |
http://cjohansen.no/sinon/ | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define an instrumentation that performs the caching | |
class CachingInstrumentation | |
def instrument(_type, field) | |
return field unless field.metadata.include?(:cache_proc) | |
old_resolver = field.resolve_proc | |
new_resolver = -> (obj, args, ctx) do | |
# Get the caching key | |
cache_key = field.metadata[:cache_proc].call(obj, args, ctx) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Service from 'path/to/service'; | |
import 'jasmine-ajax' | |
describe('Service', () => { | |
let request, promise; | |
let instance = Service; | |
let payload = {foo:'bar'}; | |
let path = '/path'; | |
let callback = jasmine.createSpy('callback'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class API::V1::BaseController < ApplicationController | |
skip_before_filter :verify_authenticity_token | |
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var content = ''; | |
var boundary = '---------------------------170062046428149'; | |
content += '--'+ boundary + '\r\n'; | |
content += 'Content-Disposition: form-data; name="uploadToken"\r\n'; | |
content += '\r\n'; | |
content += upload_token + '\r\n'; | |
content += '--'+ boundary + '\r\n'; | |
content += 'Content-Disposition: form-data; name="destFolderPath"\r\n'; | |
content += '\r\n'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Prepare ################################################################### | |
# Remove RVM | |
rvm implode | |
# Ensure your homebrew is working properly and up to date | |
brew doctor | |
brew update | |
## Install ################################################################### |
OlderNewer