code
stringlengths
1
1.73M
language
stringclasses
1 value
# Be sure to restart your server when you modify this file. # Your secret key for verifying cookie session data integrity. # If you change this key, all old sessions will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Act...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying do debug a probl...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between...
Ruby
# Be sure to restart your server when you modify this file # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
Ruby
# Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? ...
Ruby
ActionController::Routing::Routes.draw do |map| map.resources :reservadas map.resources :reservadatahorarios map.resources :reservas map.resources :turmas map.calendar '/calendar/:year/:month', :controller => 'calendar', :action => 'index', :requirements => {:year => /\d{4}/, :month => /\d{1,2}/}, :year =>...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module UsuariosHelper end
Ruby
module CalendarHelper def month_link(month_date) link_to(I18n.localize(month_date, :format => "%B"), {:month => month_date.month, :year => month_date.year}) end # custom options for this calendar def event_calendar_opts { :year => @year, :month => @month, :event_strips => @event_st...
Ruby
module ReservadatahorariosHelper end
Ruby
module MateriasHelper end
Ruby
module MainHelper module FormHelper # Returns an input tag of type "number". # # ==== Options # * Accepts same options as number_field_tag def number_field(object_name, method, options = {}) ::ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_f...
Ruby
module TipousuariosHelper end
Ruby
module SalasHelper end
Ruby
module HorariosHelper end
Ruby
module ReservasHelper end
Ruby
module TurmasHelper end
Ruby
module ReservadasHelper end
Ruby
module EquipamentosHelper end
Ruby
class Event < ActiveRecord::Base has_event_calendar end
Ruby
class Reservadatahorario < ActiveRecord::Base belongs_to :reserva end
Ruby
class Equipamento < ActiveRecord::Base belongs_to :salas end
Ruby
class Reservadas < ActiveRecord::Base has_many :reserva has_many :reservadatahorario has_many :usuario has_many :materia has_many :sala end
Ruby
class Usuario < ActiveRecord::Base has_one :turma has_many :materia belongs_to :tipousuario before_create :hash_senha validates_uniqueness_of :matricula validates_presence_of :matricula, :senha attr_protected :id def hash_senha self.senha = Digest::MD5.hexdigest(self.senha) end def self.au...
Ruby
class Sala < ActiveRecord::Base has_many :equipamento end
Ruby
class Reserva < ActiveRecord::Base belongs_to :usuario belongs_to :sala belongs_to :materia has_many :reservadatahorario end
Ruby
class Horario < ActiveRecord::Base end
Ruby
class Tipousuario < ActiveRecord::Base has_many :usuario end
Ruby
class Turma < ActiveRecord::Base belongs_to :usuario belongs_to :materia end
Ruby
class Main < ActiveRecord::Base has_many :usuario has_many :tipousuario end
Ruby
class Materia < ActiveRecord::Base belongs_to :usuario has_one :turma end
Ruby
class SalasController < ApplicationController # GET /salas # GET /salas.xml def index @salas = Sala.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @salas } end end # GET /salas/1 # GET /salas/1.xml def show @sala = Sala.find(params[:id]) ...
Ruby
class ReservasController < ApplicationController # GET /reservas # GET /reservas.xml def index @reservas = Reserva.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @reservas } end end # GET /reservas/1 # GET /reservas/1.xml def show @reserv...
Ruby
class UsuariosController < ApplicationController # GET /usuarios # GET /usuarios.xml def index @usuarios = Usuario.all respond_to do |format| format.js format.html # index.html.erb format.xml { render :xml => @usuarios } end end # GET /usuarios/1 # GET /usuarios/1.xml def s...
Ruby
class HorariosController < ApplicationController # GET /horarios # GET /horarios.xml def index @horarios = Horario.all @horario= Horario.new respond_to do |format| format.html # index.html.erb format.xml { render :xml => @horarios } end end # GET /horarios/1 # GET /horarios/1....
Ruby
class ReservadasController < ApplicationController def index @reservas=Reservadatahorario.find(:all) end end
Ruby
class MainController < ApplicationController before_filter :login_required, :only=>['welcome', 'hidden'] def index render :action => 'login' end def login if request.post? if session[:usuario] = Usuario.authenticate(params[:usuario][:matricula], params[:usuario][:senha]) flash[:aviso] = "...
Ruby
class ReservadatahorariosController < ApplicationController # GET /reservadatahorarios # GET /reservadatahorarios.xml def index @reservae = Reserva.find(params[:id]) @reservadatahorarios = Reservadatahorario.find(:all,:conditions=>["reserva_id = ?",@reservae.id]) @reservadatahorario = Reservadatahora...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryPr...
Ruby
class EquipamentosController < ApplicationController # GET /equipamentos # GET /equipamentos.xml def index @salae = Sala.find(params[:id]) @equipamentos = Equipamento.find(:all,:conditions=>["sala_id = ?",@salae.id]) @equipamento = Equipamento.new respond_to do |format| format.html # index.h...
Ruby
class TurmasController < ApplicationController # GET /turmas # GET /turmas.xml def index @turmas = Turma.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @turmas } end end # GET /turmas/1 # GET /turmas/1.xml def show @turma = Turma.find(par...
Ruby
class CalendarController < ApplicationController def index @month = (params[:month] || (Time.zone || Time).now.month).to_i @year = (params[:year] || (Time.zone || Time).now.year).to_i @shown_month = Date.civil(@year, @month) @event_strips = Event.event_strips_for_month(@shown_month) end end
Ruby
class MateriasController < ApplicationController # GET /materias # GET /materias.xml def index @materias = Materia.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @materias } end end # GET /materias/1 # GET /materias/1.xml def show @materi...
Ruby
class TipousuariosController < ApplicationController # GET /tipousuarios # GET /tipousuarios.xml def index @tipousuarios = Tipousuario.all @tipousuario= Tipousuario.new respond_to do |format| format.html # index.html.erb format.xml { render :xml => @tipousuarios } end end # GET /...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
class CreateMaterias < ActiveRecord::Migration def self.up create_table :materias do |t| t.string :nome t.integer :credito t.boolean :obrigatoria t.integer :usuario_id t.timestamps end end def self.down drop_table :materias end end
Ruby
class CreateSalas < ActiveRecord::Migration def self.up create_table :salas do |t| t.string :nome t.string :local t.integer :qtdalunos t.timestamps end end def self.down drop_table :salas end end
Ruby
class CreateReservas < ActiveRecord::Migration def self.up create_table :reservas do |t| t.integer :usuario_id t.integer :sala_id t.integer :materia_id t.timestamps end end def self.down drop_table :reservas end end
Ruby
class CreateTurmas < ActiveRecord::Migration def self.up create_table :turmas do |t| t.string :nome t.integer :usuario_id t.integer :materia_id t.timestamps end end def self.down drop_table :turmas end end
Ruby
class CreateTipousuarios < ActiveRecord::Migration def self.up create_table :tipousuarios do |t| t.string :tipo t.timestamps end end def self.down drop_table :tipousuarios end end
Ruby
class CreateEvents < ActiveRecord::Migration def self.up create_table :events do |t| t.string :name t.datetime :start_at t.datetime :end_at t.timestamps end end def self.down drop_table :events end end
Ruby
class CreateHorarios < ActiveRecord::Migration def self.up create_table :horarios do |t| t.time :horario end end def self.down drop_table :horarios end end
Ruby
class CreateUsuarios < ActiveRecord::Migration def self.up create_table :usuarios do |t| t.integer :matricula t.string :senha t.string :nome t.integer :tipousuario_id t.timestamps end add_index(:usuarios, [:tipousuario_id, :matricula], :unique => true) end def self....
Ruby
class CreateEquipamentos < ActiveRecord::Migration def self.up create_table :equipamentos do |t| t.string :nome t.integer :sala_id t.integer :quantidade t.timestamps end end def self.down drop_table :equipamentos end end
Ruby
class CreateReservadatahorarios < ActiveRecord::Migration def self.up create_table :reservadatahorarios do |t| t.integer :reserva_id t.date :data t.time :inicio t.time :fim t.timestamps end end def self.down drop_table :reservadatahorarios end end
Ruby
class CreateReservadas < ActiveRecord::Migration def self.up create_table :reservadas do |t| t.timestamps end end def self.down drop_table :reservadas end end
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Major.create(:name...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test da...
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "stylesheets" sass_dir = "sass" images_dir = "images" javascripts_dir = "javascripts" # You can select your preferred output style here (can be overridden via the command line): # output_styl...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'xmlsimple' if ARGV.size < 1 puts "xml.rb dump <ts file>" puts "xml.rb xml <ts file> <translated file>" exit end if ARGV[0] == "dump" in_xml = ARGV[1] xml = XmlSimple.xml_in(in_xml) xml['context'].each do |i| i['message'].each do |j| puts j['sourc...
Ruby
#Isto funciona class Teste def initialize(p1,p2) @v1 = p1 @v2 = p2 end def show puts "#{@v1},#{@v2} end end class Teste2 < Teste def initialize(p1,p2) super end end t1 = Teste::new(1,2) t2 = Teste2::new(3,4) t1.show t2.show
Ruby
#Isto funciona class Teste def initialize(p1,p2) @v1 = p1 @v2 = p2 end\par def show puts "#{@v1},#{@v2} end end class Teste2 < Teste def initialize(p1) super(p1,0) end end t1 = Teste::new(1,2) t2 = Teste2::new(3) t1.show t2.show
Ruby
if __FILE__ == $0 # TODO Generated stub end puts "modulo 04"
Ruby
if __FILE__ == $0 # TODO Generated stub end puts "teste" puts "modulo 03"
Ruby
class Carro attr_reader :marca, :modelo, :cor, :tanque attr_writer :cor @@x = 0 def initialize(marca,modelo,cor,tanque) @marca = marca # marca deo carro @modelo = modelo @cor = cor @tanque = tanque @@x +=1 end def to_s "marca: #{@marca} capacidade do tan...
Ruby
class Carro def initialize(marca,modelo,cor,tanque) @marca = marca # marca deo carro @modelo = modelo @cor = cor @tanque = tanque @litros_no_tanque = tanque end def to_s "marca: #{@marca} capacidade do tanque:#{@tanque}" end def marca @marca end de...
Ruby
class Myclass def initialize( aName, aDescription ) @name = aName @description = aDescription end end ob = Myclass.new('macaco','jhjhjhjh ghg') p(ob)
Ruby
puts "Digite o numero de fluxos de caixa a ser analisado" tam = gets puts tam vetor = Array.new puts "Digite os valores dos fluxos" for x in 0 ...2 puts "Digite o valor do fluxo do periodo #{x+1}" vetor[x] = gets end vlp=15 tir = 0 j = 0 flux=0 descap = 0 puts "Digite o valor do investimento" inv = get...
Ruby
# Ruby Sample program from www.sapphiresteel.com # Create classes and use instance variables such as @myname class Dog def set_name( aName ) @myname = aName end def get_name return @myname end def talk return 'woof!' end end class Cat def set_name( aName ) @myname = aNam...
Ruby
if __FILE__ == $0 # TODO Generated stub end puts "modulo 02"
Ruby
# Uncomment this line to define a global platform for your project # platform :ios, "6.0" source 'https://github.com/CocoaPods/Specs.git' target "AloTruyen" do pod "MagicalRecord" end target "AloTruyenTests" do end
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people...
Ruby
class << ActiveRecord::Base def concerned_with(*concerns) concerns.each do |concern| require_dependency "#{name.underscore}/#{concern}" end end end
Ruby