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
def foo(a=:default, b) | |
puts "a=#{a}, b=#{b}" | |
end | |
foo(:value) | |
foo(:x, :y) |
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 RiakCallback | |
def before_destroy(record) | |
raise 'Invalid Riak Client' unless record.walk_server_client.is_a? Riak::Client | |
@client = record.walk_server_client | |
record.riak_keys.each do |key| | |
delete(key[0], key[1]) | |
end | |
end | |
def exists?(key, bucket_name) |
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
# 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') |
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 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 |
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 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 |
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
### 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 :) |
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
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 |
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
<!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" %> |
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
<!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" %> |
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
<!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"> |