Skip to content

Instantly share code, notes, and snippets.

@gerep
gerep / spree.rb
Created September 10, 2013 14:06
Spree.config do |config|
config.logo = "logo.png"
config.use_s3 = true
config.s3_bucket = "asdasd"
config.s3_access_key = "asdasd"
config.s3_secret = "asdasd"
end
module Spree
CheckoutController.class_eval do
def update
if @order.update_attributes(object_params)
fire_event('spree.checkout.update')
return if after_update_attributes
unless @order.next
flash[:error] = @order.errors[:base].join("\n")
redirect_to checkout_state_path(@order.state) and return
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Funções JavaScript - Exemplos de uso</title>
</head>
<body>
</body>
<script type="text/javascript">
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "2Pay" %></title>
<meta name="description" content="2Pay">
<meta name="author" content="Plano Bê">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "2Pay" %></title>
<meta name="description" content="2Pay">
<meta name="author" content="Plano Bê">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
def self.total_volume(transactions)
total = 0
if transactions.is_a?(Array)
transactions.each do |transaction|
total += transaction.amount
end
else
total += transactions.amount
end
total
@gerep
gerep / .bash_profile
Created October 11, 2013 03:38
Aliases for RVM
### RVM aliases
alias project_one="rvm use 1.9.3@project_one"
alias project_two="rvm use 2.0.0@rails3213"
alias project_three="rvm use 1.9.3@rails4"
alias project_four="rvm use 1.9.3@project_four"
#You'll create gemsets that will make sense on your project, this is just an example and I hope it will help you :)
class RiakWrapper
def self.setup
walk_server = WalkServer.first
@client ||= Riak::Client.new(:protocol => "pbc", :host => walk_server.host, :pb_port => walk_server.pb_port)
end
def self.exists?(key, bucket_name)
get_bucket(bucket_name)
@bucket.exists?(key)
end
class RiakWrapper
def initialize
walk_server = WalkServer.first
@client = Riak::Client.new(:protocol => "pbc", :host => walk_server.host, :pb_port => walk_server.pb_port)
end
def exists?(key, bucket_name)
bucket(bucket_name).exists?(key)
end
# HERE IS HOW I USE RIAKWRAPPER
#
def destroy_on_riak
# DELETING ON RIAK
acronym = current_company.acronym
wrapper = RiakWrapper.new(walk_server_client)
wrapper.delete("#{acronym}_#{self.number}", 'terminals')
wrapper.delete("#{acronym}_#{self.number}_params.dat", 'assets')