code
stringlengths
1
1.73M
language
stringclasses
1 value
class AddColunmNameComputer < ActiveRecord::Migration def self.up add_column :computers, :name, :string end def self.down remove_column :computers, :name end end
Ruby
class CreateTypeEvents < ActiveRecord::Migration def self.up create_table :type_events do |t| t.string :name t.timestamps end end def self.down drop_table :type_events end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :email t.string :password_hash t.string :password_salt t.timestamps end end def self.down drop_table :users end end
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
#!/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/runner'
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/destroy'
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/console'
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__) $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/server'
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/plugin'
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/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/generate'
Ruby
require 'thread' class Cron < ActiveRecord::Base threads = [] threads << Thread.new do while true do puts "activation agent" Computer.agent sleep(120) end end threads << Thread.new do while true do puts "simulation infection" Virus.infection sleep(22...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def authenticated?() not session[:user_id].nil? end end
Ruby
module SessionHelper end
Ruby
module EventsHelper end
Ruby
module RoomsHelper end
Ruby
module UsersHelper end
Ruby
module ComputersHelper end
Ruby
module TypeEventsHelper end
Ruby
class Room < ActiveRecord::Base has_many :computer, :dependent =>:nullify validates_presence_of :name end
Ruby
class Event < ActiveRecord::Base belongs_to :type_event belongs_to :computer validates_associated :type_event validates_presence_of :information validates_presence_of :computer_id validates_presence_of :type_event_id end
Ruby
class VirusDatabase < ActiveRecord::Base has_many :computer has_many :softwares end
Ruby
class BaseVirale < ActiveRecord::Base end
Ruby
class Virus < ActiveRecord::Base belongs_to :virus_type def self.infection @computer = Computer.find(:first, :order => "RAND()") @virus = self.find(:first, :order => "RAND()") event_tab = { "information" => "infection par #{@virus.name}", "state" => 1, "computer_id" => @...
Ruby
class Softwares < ActiveRecord::Base has_many :computers, :dependent =>:nullify end
Ruby
class VirusTypes < ActiveRecord::Base end
Ruby
class TypeEvent < ActiveRecord::Base end
Ruby
require 'digest/md5' class User < ActiveRecord::Base attr_accessible :email, :password, :password_confirmation attr_accessor :password before_save :encrypt_password validates_confirmation_of :password validates_presence_of :password, :on => :create validates_presence_of :email validates_uniqueness_of...
Ruby
class Computer < ActiveRecord::Base belongs_to :room belongs_to :softwares has_many :events, :dependent => :delete_all validates_numericality_of :cpu validates_numericality_of :ram validates_numericality_of :hard_drive validates_numericality_of :cpu_used validates_numericality_of :ram_used validates_numeri...
Ruby
class EventsController < ApplicationController before_filter :check_authentication, :only => [:edit, :delete, :update] # GET /events # GET /events.xml def index #@events = Event.all @events = TypeEvent.find(:all, :joins => "INNER JOIN events ON type_events.id = events.type_event_id INNER JOIN...
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
#gem "C:/Ruby187/lib/ruby/gems/1.8/gems/googlecharts-1.6.8/lib/googlecharts", :require => "gchart" class StatsController < ApplicationController def index begin require "gchart" #recuperer les date entrees dans le formulaire if(params['dated']) @date_debut = Date.new(params[:d...
Ruby
class SessionController < ApplicationController def new end def create if(params[:email]=="" || params[:password]=="") flash[:warning] ="Veuillez remplir tous les champs" redirect_to login_url else user = User.authenticate(params[:email], params[:password]) if user session[:user_id] = user.id flash...
Ruby
class UsersController < ApplicationController # GET /users # GET /users.xml def index @users = User.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @users } end end # GET /users/1 # GET /users/1.xml def show @user = User.find(params[:id])...
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 # See ActionController::RequestForgeryProtection for details...
Ruby
class RoomsController < ApplicationController # GET /rooms # GET /rooms.xml def index @rooms = Room.find(:all, :order => 'name') @events_temp = Room.find(:all, :joins => " RIGHT JOIN computers ON rooms.id = computers.room_id LEFT JOIN events ON computers.id = events.computer_id", :from =>...
Ruby
class TypeEventsController < ApplicationController # GET /type_events # GET /type_events.xml def index @type_events = TypeEvent.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @type_events } end end # GET /type_events/1 # GET /type_events/1.xml ...
Ruby
class ComputersController < ApplicationController # GET /computers # GET /computers.xml before_filter :check_authentication, :only => [:edit, :delete, :update] def index @computers = Computer.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @computers } end 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): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
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
# Be sure to restart your server when you modify this file. # These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveReco...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
# 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
ActionController::Routing::Routes.draw do |map| map.resources :users map.resources :events map.resources :type_events map.resources :rooms map.resources :computers map.resources :stats #get "log_out" => "sessions#destroy", :as => "log_out" #get "log_in" => "sessions#new", :as => "log_in" #get "s...
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
# 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.4' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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
# 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
# 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.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
class AddRoomRelationship < ActiveRecord::Migration def self.up add_column :boxes, :room_id, :integer, :null => false add_index :boxes, :room_id Room.create! :name => 'Salle principale' if Room.count == 0 Box.update_all :room_id => Room.find(:first).id end def self.down remove_column :boxes, ...
Ruby
class CreateRooms < ActiveRecord::Migration def self.up create_table :rooms do |t| t.column :name, :string, :limit =>128 end Room.create! :name => 'Salle principale' end def self.down drop_table :rooms end end
Ruby
class CreateIncidents < ActiveRecord::Migration def self.up create_table :incidents do |t| t.column :kind, :string t.column :data, :string t.column :resolve, :string t.column :created_at, :datetime t.column :updated_at, :datetime end end def self.down drop_table :incide...
Ruby
class AddBoxRelations < ActiveRecord::Migration def self.up add_column :incidents, :box_id, :integer, :null => false add_index :incidents, :box_id end def self.down remove_column :incidents, :box_id end end
Ruby
class AddIncidentResolveDate < ActiveRecord::Migration def self.up add_column :incidents, :resolved_at, :datetime, :null => true end def self.down remove_column :incidents, :resolved_at end end
Ruby
class CreateBoxes < ActiveRecord::Migration def self.up create_table :boxes do |t| t.column :name, :string, :limit => 128 t.column :ip, :string, :limit => 20 end if Box.count == 0 then Box.create! :name => 'pc_1.1', :ip => '192.168.65.1' #, :room_id => 1 Box.create! :name => 'pc_1....
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.column :login, :string, :limit => 64 t.column :hashed_password, :string, :limit => 40 t.column :salt, :string, :limit => 32 t.column :firstname, :string, :limit => 64 t.column :lastname, :string, :li...
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
class Room < ActiveRecord::Base #une salle a plusieurs machines has_many :boxes validates_presence_of :name end
Ruby
class Box < ActiveRecord::Base #une machine se trouve que dans une salle belongs_to :room validates_presence_of :name, :ip validates_uniqueness_of :name, :ip end
Ruby