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 Foo < ActiveRecord::Base | |
class MyOwnHash | |
def self.dump(hash) | |
hash.to_json | |
end | |
def self.load(hash) | |
(hash || {}).with_indifferent_access | |
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 MyRedis | |
def self.conn | |
connect unless @conn | |
begin | |
@conn.ping | |
rescue Redis::BaseConnectionError | |
raise if @tried | |
@tried = true | |
connect | |
retry |
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
Foo: 1 bar |
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
[14] pry(main)> params = {"authenticity_token"=>"qNm7AlvhnrQoWc3XqN1csWfDauWDNUzkiv0ARa1jJPQ=", "evento"=>{"id"=>"", "situacao"=>"1", "nome"=>"teste", "apresentacao"=>"<p>teste</p>\r\n", "coordenador_id"=>"21243", "exibir_gabarito"=>"0", "exibir_estatistica_individual"=>"0", "exibir_forum"=>"0", "inicio"=>"09/04/2015", "fim"=>"09/10/2015", "fase_do_evento_id"=>"1", "duracao"=>"5", "tipo_questao_id"=>"1", "ponto_acerto"=>"0.0", "ponto_erro"=>"0.0", "ponto_aprovacao"=>"0.0"}, "aproveitamentos_produto"=>{"aproveitamento_id"=>["1"]}, "grupo_novo"=>[{"area_conhecimento_id"=>"15", "total_questoes"=>"1", "ponto_corte"=>"1", "ordem"=>"1"}]} | |
=> {"authenticity_token"=>"qNm7AlvhnrQoWc3XqN1csWfDauWDNUzkiv0ARa1jJPQ=", | |
"evento"=> | |
{"id"=>"", | |
"situacao"=>"1", | |
"nome"=>"teste", | |
"apresentacao"=>"<p>teste</p>\r\n", | |
"coordenador_id"=>"21243", | |
"exibir_gabarito"=>"0", | |
"exibir_estatistica_individual"=>"0", |
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
[7] pry(main)> f = Foo.new | |
=> #<Foo:0x007ff0f3cbfd68 id: nil, name: nil, created_at: nil, updated_at: nil> | |
[8] pry(main)> f.changes | |
=> {} | |
[9] pry(main)> f.name = "Blah" | |
=> "Blah" | |
[10] pry(main)> f.changes | |
=> {"name"=>[nil, "Blah"]} | |
[11] pry(main)> |
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
ActiveRecord::Migration.class_eval do | |
def create_or_replace_view view | |
execute File.read(Rails.root.join "db/views/#{view}.sql") | |
end | |
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
ActiveRecord::Migration.class_eval do | |
def create_or_replace_view view | |
execute File.read(Rails.root.join "db/views/#{view}.sql") | |
end | |
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
SELECT a.attname, format_type(a.atttypid, a.atttypmod), | |
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod | |
FROM pg_attribute a LEFT JOIN pg_attrdef d | |
ON a.attrelid = d.adrelid AND a.attnum = d.adnum | |
WHERE a.attrelid = 'researchers'::regclass | |
AND a.attnum > 0 AND NOT a.attisdropped | |
ORDER BY a.attnum |
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
location ~* ^/convenient_url/(.+)$ { | |
internal; | |
set $host_name some.secret.cdn.hostname.com; | |
set $content_ip 10.11.12.13; | |
set $content_url http://$content_ip/$1; | |
proxy_set_header Host $host_name; | |
add_header Content-Type 'application/octet-stream'; |
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
Pry::Commands.block_command 'r' do |*w| | |
run "show-routes" + ( w.present? ? " --grep '#{w.join ' '}'" : "" ) | |
end |