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
HTTParty.post("https://desenvolvedor.moip.com.br/sandbox", | |
:headers => { | |
'Accept' => 'application/xml', | |
'Content-Type' => 'application/xml; charset=ISO-8859-1' | |
}, | |
:user => "MOIP_API_TOKEN:MOIP_API_KEY" | |
) |
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
# app/presenters/product_presenter.rb | |
class ProductPresenter < Presenter | |
def description | |
# ... | |
end | |
end | |
# app/presenters/person_presenter.rb | |
class PersonPresenter < Presenter | |
def 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
class Integer | |
@@results = [] | |
def happy? | |
value = digits_square_sum | |
return false if @@results.include?(value) | |
if value == 1 | |
@@results = [] |
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 update | |
if @concert.update(params[:concert]) | |
@concert.confirm! | |
redirect_to user_concert_path(current_user, @concert), notice: t('flash.concerts.update_success') | |
else | |
@top_tippers = ConcertPayment.top_tippers(@concert).limit(5) # isso daqui dá pra melhorar, chamar @concert.top_tippers é mais legível | |
@concert_payments = @concert.concert_payments # se não for usar na view, nao precisa ser variavel de instancia esse @concert_payments | |
@amount = @concert_payments.amount # => faz scope disso map(&:amount).sum, sem usar os métodos do ruby. Faça um sql. | |
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
# app/business/concert/update.rb | |
# Concert::RescheduleEmail.sent(concert, new_time) | |
class Concert::RescheduleEmail | |
def self.sent(concert, new_time) | |
new(concert, new_time).sent | |
end | |
def initialize(concert, new_time) | |
@concert, @starts_at = concert, new_time.to_time |
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 embed(youtube_url) | |
content_tag(:iframe, nil, src: youtube_url) | |
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 Object | |
def self.attributes(*attrs) | |
attrs.each do |attr| | |
define_method attr do | |
instance_variable_get "@#{attr}" | |
end | |
define_method "#{attr}=" do |value| | |
instance_variable_set "@#{attr}", value | |
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
source /usr/local/git/contrib/completion/git-completion.bash | |
complete -C "/usr/bin/gemedit --complete" gemedit | |
export WORKON_HOME=~/.env | |
export JAVA7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home | |
export JAVA6_HOME=/Library/Java/Home | |
export JAVA_HOME=$JAVA6_HOME | |
export PATH=$JAVA_HOME/bin:$PATH | |
export SBT_OPTS="-XX:MaxPermSize=256M" |
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 UserAccount | |
include LinkWithFacebook | |
include LinkWithTwitter | |
include SignUpWithFacebook | |
include SignUpWithTwitter | |
def initialize(params) | |
@user_params = params[:user] | |
@social_params = params[:social] | |
end |
OlderNewer