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 Remote | |
def initialize(door) | |
@door = door | |
end | |
def press_button | |
puts "Pressing the remote control button..." | |
if @door.is_open | |
@door.close |
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 CustomReports | |
def self.relatorio_geral(imobiliaria,tipo, collection, block) | |
RGhost::Document.new :paper => :A4, :margin_left => 0.2, :margin_right => 0.2, :margin_bottom => 2 do |doc| | |
doc.define_tags do | |
tag :small, :name => 'Verdana', :size => 12 | |
tag :default, :name => 'Verdana', :size => 15 | |
tag :title, :name => 'Verdana', :size => 17 | |
tag :header1, :name => 'Verdana', :size => 20 | |
tag :header2, :name => 'Verdana', :size => 26 | |
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
import java.io.FileWriter; | |
import java.io.IOException; | |
import javax.servlet.http.HttpSessionEvent; | |
import javax.servlet.http.HttpSessionListener; | |
public class Logger implements HttpSessionListener{ |
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
module PrecoReal | |
def self.included( base ) | |
@base = base | |
end | |
def atributo_em_real(*args) | |
args.each do |arg| |
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 show | |
@page_title = @cliente | |
@imoveis = @cliente.imoveis | |
@alugueis_atuais = Aluguel.atuais.all( :conditions => { :imovel_id => @imoveis.map(&:id) } ) | |
@imoveis_alugados = Imovel.all( :conditions => {:id => @alugueis_atuais.map(&:imovel_id)}) | |
@alugueis_anteriores = @cliente.alugueis | |
@contas = @cliente.contas.a_vencer | |
@atendimentos = @cliente.atendimentos | |
@contas_imoveis_all = imobiliaria_atual.contas.all( :conditions => { :referente_id => @alugueis_atuais.map(&:id), :referente_type => 'Aluguel' } ) | |
@contas_imoveis = if params[:busca_de_contas].blank? |
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
public void removerLojas(){ | |
Query query = manager.createQuery("select l from Loja l"); | |
List<Loja> lojas = query.getResultList(); | |
Loja loja = lojas.get(0); | |
List<Produto> produtos = loja.getProdutos(); | |
Produto produto = produtos.get(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
package controllers; | |
import helpers.Redirector; | |
import helpers.Resource; | |
import java.io.IOException; | |
import java.util.List; | |
import javax.persistence.EntityManager; | |
import javax.persistence.Query; |
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
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | |
this.redirect = new Redirector(request, response); | |
if (request.getParameter("id")==null){ | |
if (request.getMethod().equals("POST")) | |
this.doCreate(request, response); | |
else | |
if (request.getParameter("method")!=null) | |
this.doNew(request, response); |
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
desc "Move paths to more specific tables." | |
task :path_moving => :environment do | |
filetemp = "tmp/temp.sql" | |
File.open(filetemp, 'w') do |file| | |
Path.paginated_each do |path| | |
if path.user_agent =~ /[B|b]ot|[B|b]aidu|[S|s]pider/ | |
file.puts "insert into `spiders_paths` (#{path.attribute_names.map{|attr| "`#{attr}`"}.join(', ')}) | |
values(#{path.attribute_names.map{|attr| "#{path.send(attr).blank? ? 'NULL' : "'#{path.send(attr).to_s.gsub(/[']/, '\\\\\'')}'"}"}.join(', ')});\n" | |
else | |
file.puts << "insert into `customers_paths` (#{path.attribute_names.map{|attr| "`#{attr}`"}.join(', ')}) |
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
desc "Moves all generated paths into different tables depending on their source (human or bots/spiders)." | |
task :path_moving => :environment do | |
database = Path.configurations[RAILS_ENV]['database'] | |
filetemp = "tmp/temp.sql" | |
last_id = nil | |
spiders = /[B|b]ot|[B|b]aidu|[S|s]pider|pingdom|xenu|sitemaps|cuil|msn|shopwiki|entireweb|tokenizer|ysearch/ | |
File.open(filetemp, 'w') do |file| | |
Path.paginated_each(:per_page => 200) do |path| | |
type = path.user_agent =~ spiders ? 'spiders' : 'humans' | |
file.puts "insert into `#{type}_paths` (#{path.attribute_names.map{|attr| "`#{attr}`"}.join(', ')}) |
OlderNewer