Skip to content

Instantly share code, notes, and snippets.

@aalvesjr
aalvesjr / gist:6d004f4103c9c6fbbcb0
Created January 21, 2015 19:17
Formatar pendrive via CMD
1. Diskpart (Uma nova janela será aberta, espere até o cursor aparecer)
2. List Disk
3. Select Disk 1 (substitua o 1 pelo número referente ao seu pendrive)
4. Clean
5. Create partition primary
6. Active
7. Format fs=fat32 quick
8. Assign
9. Exit
@aalvesjr
aalvesjr / gist:a66abd94259da003bf5d
Created January 12, 2015 21:56
Atualizar Ubuntu via terminal
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo apt-get -y clean
sudo reboot
// Preparando ambiente
$ sudo apt-get -y install build-essential vim openssl curl git-core
@aalvesjr
aalvesjr / gist:0214e2bd3eac714f4d69
Created August 13, 2014 22:46
map e reduce em JS
var products = [
{name: "Product A"}
,{name: "Product B", price: 100}
,{name: "Product C", price: 200}
,{name: "Product D", offerPrice: 100, price: 150}
];
function filterPrice(product){
var price = product["offerPrice"] ? product["offerPrice"] : product["price"];
return price ? price : 0;
@aalvesjr
aalvesjr / err.txt
Created March 20, 2013 04:52
Erro ao tentar iniciar o rails usando a gem CleanLogger
$ rails s
/usr/lib/ruby/gems/2.0.0/gems/clean_logger-0.0.2/lib/clean_logger.rb:6:in `<module:CleanLogger>': uninitialized constant ActiveSupport::Logger (NameError)
from /usr/lib/ruby/gems/2.0.0/gems/clean_logger-0.0.2/lib/clean_logger.rb:5:in `<top (required)>'
from /usr/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
from /usr/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /usr/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
from /usr/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
from /usr/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
from /usr/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require'
from /usr/lib/ruby/gems/2.0.0/gems/bundler-1.3.4/lib/bundler.rb:132:in `require'
@aalvesjr
aalvesjr / trace.txt
Created February 27, 2013 17:49
erro ao usar symbol
2013-02-27T17:48:24Z 19956 TID--9tjdlm Qe::Sidekiq::Worker JID-aa29bc17e817106ea5074e1d INFO: start
2013-02-27T17:48:24Z 19956 TID--9tjdlm Qe::Sidekiq::Worker JID-aa29bc17e817106ea5074e1d INFO: fail: 0.004 sec
2013-02-27T17:48:24Z 19956 TID--9tjdlm WARN: {"retry"=>true, "queue"=>"default", "class"=>"Qe::Sidekiq::Worker", "args"=>["MailerWorker", {"mail"=>"new_password_mail", "name"=>"Usuario", "email"=>"[email protected]"}], "jid"=>"aa29bc17e817106ea5074e1d", "error_message"=>"nil is not a symbol", "error_class"=>"TypeError", "failed_at"=>2013-02-27 17:48:24 UTC, "retry_count"=>0}
2013-02-27T17:48:24Z 19956 TID--9tjdlm WARN: nil is not a symbol
2013-02-27T17:48:24Z 19956 TID--9tjdlm WARN: /var/www/gvar/releases/20130226060346/app/services/mailer_worker.rb:5:in `public_send'
/var/www/gvar/releases/20130226060346/app/services/mailer_worker.rb:5:in `perform'
/var/www/gvar/shared/bundle/ruby/2.0.0/gems/qe-0.2.1/lib/qe/worker.rb:24:in `block in perform'
/var/www/gvar/shared/bundle/ruby/2.0.0/gems/qe-0.2.1/lib/qe/wo
@aalvesjr
aalvesjr / teste.rb
Last active December 14, 2015 07:19
class MailerWorker
include Qe::Worker
def perform
# ChangePasswordMailer.public_send(options[:mail], options).deliver # da erro que nil não pode ser enviado ao public_send
ChangePasswordMailer.public_send(options["mail"], options).deliver
end
end
class ChangePasswordMailer < ActionMailer::Base
@aalvesjr
aalvesjr / redis.txt
Created February 25, 2013 21:09
Instalando REDIS no Ubuntu 12.04
# Execute
# Remove a versão 8.4 do Tcl
sudo apt-get remove tk8.4 tcl8.4
# Instala a versão 8.5
sudo apt-get install tk8.5 tcl8.5
# Baixa o .tar do REDIS
wget http://download.redis.io/redis-stable.tar.gz
@aalvesjr
aalvesjr / funcs.rb
Last active December 14, 2015 01:39
Exemplo de programação funcional em Ruby
multiple = -> num_one {
return -> num_two {
num_one * num_two
}
}
# => Proc
double = multiple.call 2
# => Proc
triple = multiple.call 3
@aalvesjr
aalvesjr / hello.rb
Created February 12, 2013 17:48
Testing Class#allocate
class Hello
def initialize
puts "New object instance of Hello class"
end
end
a = Hello.new
# => New object instance of Hello class
# => #<Hello:0x2368470>
@aalvesjr
aalvesjr / application_controller.rb
Last active December 11, 2015 23:18
Refactor ApplicationController to GVAR
# -*- encoding:utf-8 -*-
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user, :logged_in?
private
def logged_in?
current_user.present?
end