code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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/process/inspector'
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/spawner'
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/server'
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/ruby ENV['RAILS_ENV'] ||= 'production' Dir.chdir(File.expand_path(File.dirname(__FILE__) + "/..")) #Change current directory to RAILS_ROOT require "config/environment" include ActionController::UrlWriter default_url_options[:host] = 'www.amtransservices.com' filename = "#{RAILS_ROOT}/public/sitemap.xml" Fi...
Ruby
#!/usr/bin/ruby ##Rail's Analyzer With Klass #run the following to view help: #ruby rawk.rb -? class Stat def initialize(key) @key=key @min = nil @max = nil @sum = 0 @sum_squares = 0 @count = 0 @values = [] end def add(value) value=1.0*value @count+=1 @min = value unless @m...
Ruby
#!/usr/bin/ruby ##Rail's Analyzer With Klass #run the following to view help: #ruby rawk.rb -? class Stat def initialize(key) @key=key @min = nil @max = nil @sum = 0 @sum_squares = 0 @count = 0 @values = [] end def add(value) value=1.0*value @count+=1 @min = value unless @m...
Ruby
class AddSpecialRequest < ActiveRecord::Migration def self.up add_column :reservations, :special_requests, :text end def self.down remove_column :reservations, :special_requests end end
Ruby
class AddIndexes < ActiveRecord::Migration def self.up add_index :reservations, [:id], :name => "idxReservationID", :unique => true add_index :feedbacks, [:id], :name => "idxFeedbackID", :unique => true end def self.down remove_index :reservations, :name => :idxReservationID remove_index :feedbac...
Ruby
class CreateFourOhFours < ActiveRecord::Migration def self.up create_table :four_oh_fours do |t| t.column "host", :string t.column "path", :string t.column "referer", :string t.column "count", :integer, :default => 0 t.timestamps end add_index :four_oh_fours, [:host, :path, :...
Ruby
class CreateFeedbacks < ActiveRecord::Migration def self.up create_table :feedbacks do |t| t.column :name, :string t.column :email, :string t.column :feedback, :text t.column :created_on, :datetime t.column :updated_on, :datetime end end def self.down drop_table :feedbac...
Ruby
class AddNeededColumnsToReservations < ActiveRecord::Migration def self.up remove_column :reservations, :duration remove_column :reservations, :vehicle_type_id add_column :reservations, :vehicle_type, :string, :limit =>100 add_column :reservations, :round_trip, :boolean, :default => 0 add_column :...
Ruby
class CreateReservations < ActiveRecord::Migration def self.up create_table :reservations do |t| t.column :name, :string t.column :phone_number, :string t.column :email, :string t.column :guests, :integer t.column :reserve_for, :datetime t.column :duration, :integer t.col...
Ruby
class CreatePages < ActiveRecord::Migration def self.up create_table :pages do |t| t.column :name, :string t.column :title, :string t.column :content_id, :integer end end def self.down drop_table :pages end end
Ruby
namespace :tmp do namespace :assets do desc "Clears javascripts/cache and cached Rails actions" task :clear => :environment do FileUtils.rm(Dir['public/javascripts/cache/[^.]*']) FileUtils.rm(Dir['public/[a-z]*.html']) end end end
Ruby
#!/usr/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired re...
Ruby
#!/usr/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired re...
Ruby
#!/usr/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log # an...
Ruby
#!/usr/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired re...
Ruby
#!/usr/bin/ruby require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired re...
Ruby
#!/usr/bin/ruby # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log # an...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::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 datab...
Ruby
require 'rake' require 'yaml' module PhpThumbHelper ROOT_DIR = File.expand_path(File.dirname(__FILE__)) SRC_DIR = File.join(ROOT_DIR, 'src') DOCS_DIR = File.join(ROOT_DIR, 'apidocs') VERSION = YAML.load(IO.read(File.join(ROOT_DIR, 'config.yml')))['CURRENT_VERSION'].gsub(' ', '-').downcase...
Ruby
#!/usr/bin/env ruby ip="128.8.126.92" file=ARGV[0] #file="data/rtt_trace.full.dat" f = File.open(file, "r") # map unacked sequence numbers to timestamps h = Hash.new { |h,k| h[k] = -1; } f.each_line do |line| timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, tot_sz, data_sz = line.split i...
Ruby
#!/usr/bin/env ruby require 'set' ip="128.8.126.92" file=ARGV[0] #file="data/rtt_trace.full.dat" f = File.open(file, "r") # map unacked sequence numbers to timestamps seqs = Set.new acks = Set.new dup_seqs = 0; dup_acks = 0; f.each_line do |line| timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, ...
Ruby
#!/usr/bin/env ruby ip="128.8.126.92" file=ARGV[0] #file="data/rtt_trace.full.dat" f = File.open(file, "r") old_time = 0 data_sum = 0 interval = 0.01 * 1000000 # 10000 microseconds = 0.01 seconds f.each_line do |line| timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, tot_sz, data_sz = line.split ...
Ruby
#!/usr/bin/env ruby ip="128.8.126.92" file=ARGV[0] #file="data/rtt_trace.full.dat" f = File.open(file, "r") old_time = 0 data_sum = 0 interval = 0.01 * 1000000 # 10000 microseconds = 0.01 seconds f.each_line do |line| timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, tot_sz, data_sz = line.split ...
Ruby
#!/usr/bin/env ruby require 'set' ip="128.8.126.92" file=ARGV[0] #file="data/rtt_trace.full.dat" f = File.open(file, "r") # map unacked sequence numbers to timestamps seqs = Set.new acks = Set.new dup_seqs = 0; dup_acks = 0; f.each_line do |line| timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, ...
Ruby
#!/usr/bin/env ruby ip="128.8.126.92" file=ARGV[0] #file="data/rtt_trace.full.dat" f = File.open(file, "r") # map unacked sequence numbers to timestamps h = Hash.new { |h,k| h[k] = -1; } f.each_line do |line| timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, tot_sz, data_sz = line.split i...
Ruby
#!/usr/bin/ruby # # cnip.rb - A class to convert IPv4 Address to Location Description # # Copyright (c) 2006 by Camel Huang. # class String def to_num3 (self + "\0").to_num4 end def to_num4 self.unpack('V*')[0] end end class CNIP class IPLocation attr_accessor :country, :area...
Ruby
#!/usr/bin/ruby # # cnip.rb - A class to convert IPv4 Address to Location Description # # Copyright (c) 2006 by Camel Huang. # class String def to_num3 (self + "\0").to_num4 end def to_num4 self.unpack('V*')[0] end end class CNIP class IPLocation attr_accessor :country, :area...
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). ActiveRecord::Base.transaction do # Categories # Control categories control_categories = [ ["Access Contr...
Ruby
class AddPersonLanguage < ActiveRecord::Migration # Add a 'language_id' association from Person to the Option table # Local models so that migration is safe class Option < ActiveRecord::Base attr_accessible :role, :title end def up add_column :people, :language_id, :integer Option.reset_column_...
Ruby
class AddDocumentOptionColumns < ActiveRecord::Migration def up change_table :documents do |t| t.text :description t.references :type t.references :kind t.references :year t.references :language end end def down change_table :documents do |t| t.remove :description ...
Ruby
class AddKindToPrograms < ActiveRecord::Migration def change add_column :programs, :kind, :string end end
Ruby
class RemoveControlIdFromRequests < ActiveRecord::Migration def up # replace all controls with adequate control assessments Request.all.each do |request| if request.control_id.present? control_assessment = ControlAssessment.where(:control_id => request.control_id, :pbc_list_id => request.pbc_lis...
Ruby
class FixRelationshipDescription < ActiveRecord::Migration def up rename_column :relationship_types, :forward_short_description, :forward_phrase rename_column :relationship_types, :backward_short_description, :backward_phrase end def down rename_column :relationship_types, :forward_phrase, :forward_s...
Ruby
class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| t.string :slug t.string :title t.text :description t.string :url t.references :modified_by t.datetime :start_date t.datetime :stop_date t.timestamps end end end
Ruby
class LinkAccountsAndPeople < ActiveRecord::Migration # This migration does a few different things: # Adds an association between accounts and people # Renames the username attribute to email in people # Links accounts to people via e-mail, creating people # as necessary to map to accounts. # Local models ...
Ruby
class AddNotesToSystems < ActiveRecord::Migration def change add_column :systems, :notes, :text end end
Ruby
class CreateControlRisks < ActiveRecord::Migration def change create_table :control_risks do |t| t.references :control, :null => false t.references :risk, :null => false t.references :modified_by t.timestamps end end end
Ruby
class ChangeStatusValues < ActiveRecord::Migration # "Draft" remains "Draft" in the new arrangement. REQUEST_STATUS_MIGRATIONS = [ ["Waiting Compliance", "Requested"], ["Waiting Auditors", "Responded (by Compliance)"], ["Completed", "Accepted (by Auditor)"] ] def up REQUEST_STATUS_M...
Ruby
class AddPopulationSampleFieldsToResponses < ActiveRecord::Migration def change add_column :responses, :population_document_id, :integer add_column :responses, :population, :integer add_column :responses, :sample_worksheet_document_id, :integer add_column :responses, :samples, :integer add_column ...
Ruby
class AddProgramIdToCycles < ActiveRecord::Migration def change add_column :cycles, :program_id, :integer end end
Ruby
class ChangePolymorphicTypesFromProgramToDirective < ActiveRecord::Migration RELATIONSHIP_TYPE_NAME_CHANGES = [ [:program_applies_to_data_asset, :directive_applies_to_data_asset], [:program_applies_to_facility, :directive_applies_to_facility], [:program_applies_to_market, :directive_applies_to_marke...
Ruby
class EnsureRequestTypeIdIsNotNil < ActiveRecord::Migration def up Request.all.reject(&:type_name).each{ |r| r.update_attribute(:type_id, 1) } end def down end end
Ruby
class CreateBaseRelationshipTypes < ActiveRecord::Migration class RelationshipType < ActiveRecord::Base self.primary_key = 'relationship_type' end def up RelationshipType.create({:relationship_type => 'within_scope_of', :description => 'The source is within the scope of the ...
Ruby
class AddReportDueAtToAuditCycle < ActiveRecord::Migration def change add_column :cycles, :report_due_at, :date end end
Ruby
class MoveImportHelpPaths < ActiveRecord::Migration def up help = Help.where(:slug => 'import').first help.update_attribute(:slug, 'systems_import') if help help = Help.where(:slug => 'import_controls').first help.update_attribute(:slug, 'controls_import') if help end def down end end
Ruby
class AddCompanyControlsProgram < ActiveRecord::Migration def up transaction do p = Program.where(:kind => "Company Controls").first if p.nil? p = Program.create(:kind => "Company Controls", :title => "Company Controls") end Directive.where(:kind => "Company Controls").each do |d|...
Ruby
class CreateResponses < ActiveRecord::Migration def change create_table :responses do |t| t.references :request t.references :system t.string :status t.references :modified_by t.timestamps end end end
Ruby
class SetDefaultKindForPrograms < ActiveRecord::Migration def up transaction do Program.all.each do |program| program.kind = "Directive" if program.kind.blank? program.save! end end end def down end end
Ruby
class AddProductStartStopDates < ActiveRecord::Migration def up change_table :products do |t| t.datetime :start_date t.datetime :stop_date end end def down change_table :products do |t| t.remove :start_date t.remove :stop_date end end end
Ruby
class UniqueSlug < ActiveRecord::Migration def up add_index :sections, :slug, :unique => true add_index :controls, :slug, :unique => true add_index :biz_processes, :slug, :unique => true add_index :systems, :slug, :unique => true add_index :programs, :slug, :unique => true end def down re...
Ruby
class FixNilRequestStatuses < ActiveRecord::Migration def up Request.where(:status => nil).all.each do |req| req.update_attribute(:status, 'Draft') end end def down end end
Ruby
class AddNewRisksFields < ActiveRecord::Migration def change change_table :risks do |t| t.text :likelihood t.text :threat_vector t.text :trigger t.text :preconditions t.text :financial_impact t.text :reputational_impact t.text :operational_impact t.integer :likeli...
Ruby
class CreateInitialTables < ActiveRecord::Migration def up create_table :accounts do |t| t.string :username t.string :name t.string :surname t.string :email t.string :crypted_password t.string :role t.string :persistence_token t.belongs_to :modified_by t.time...
Ruby
class AddNotesToControls < ActiveRecord::Migration def change add_column :controls, :notes, :text end end
Ruby
class AddObjectObjectStartStopDates < ActiveRecord::Migration def up change_table :object_people do |t| t.datetime :start_date t.datetime :stop_date end change_table :object_documents do |t| t.datetime :start_date t.datetime :stop_date end end def down change_table :ob...
Ruby
class ChangeLikelihoodPg < ActiveRecord::Migration def _is_postgresql? begin ActiveRecord::Base.connection.kind_of?( ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) rescue false end end def up if _is_postgresql? connection.execute(%q{ alter table risks...
Ruby
class AddMissingSystemFields < ActiveRecord::Migration def up change_table :systems do |t| t.datetime :start_date t.datetime :stop_date t.string :url t.string :version end end def down change_table :systems do |t| t.remove :start_date t.remove :stop_date t.re...
Ruby
class MovePbcListsColumnsToCycles < ActiveRecord::Migration def up change_table :cycles do |t| t.string :title t.string :audit_firm t.string :audit_lead t.text :description t.string :status t.text :notes end Cycle.reset_column_information Cycle.all.each do |cycle|...
Ruby
class ChangePolymorphicTypesToProgramFromDirective < ActiveRecord::Migration RELATIONSHIP_TYPE_NAME_CHANGES = [ [:directive_applies_to_data_asset, :program_applies_to_data_asset], [:directive_applies_to_facility, :program_applies_to_facility], [:directive_applies_to_market, :program_applies_to_marke...
Ruby
class CreateControlAssessments < ActiveRecord::Migration def change create_table :control_assessments do |t| t.references :pbc_list t.references :control t.string :control_version t.boolean :internal_tod, :default => nil, :null => true t.boolean :internal_toe, :default => nil, :null ...
Ruby
class AddBaseProgramKinds < ActiveRecord::Migration def up Option.where(:role => 'program_type').destroy_all role = 'program_kind' Option.where(:role => role, :title => 'Not Applicable').destroy_all [ 'Regulation', 'Company Policy', 'Operational Group Policy', 'Data Asset Policy' ].each d...
Ruby
class RemoveDirectiveIdFromCycles < ActiveRecord::Migration def up remove_column :cycles, :directive_id end def down add_column :cycles, :directive_id, :integer end end
Ruby
class AddAssertionsToControls < ActiveRecord::Migration def change change_table :controls do |t| t.boolean :fraud_related t.boolean :key_control t.boolean :active end end end
Ruby
class ConsolidateRiskFields < ActiveRecord::Migration def up transaction do Risk.all.each do |risk| impact = [risk.financial_impact, risk.reputational_impact, risk.operational_impact] impact = impact.map(&:presence).compact.join("<br />") risk.update_attribute(:impact, impact) ...
Ruby
class CreatePrograms < ActiveRecord::Migration def change create_table :programs do |t| t.string :slug t.string :title t.text :description t.string :url t.references :modified_by t.datetime :start_date t.datetime :stop_date t.timestamps end end end
Ruby
class CreateRelationships < ActiveRecord::Migration def change create_table :relationships do |t| t.references :source, :polymorphic => true, :null => false t.references :destination, :polymorphic => true, :null => false t.references :modified_by t.string :relationship_type_id t.time...
Ruby
class FixCategoryScopes < ActiveRecord::Migration def up # Fix previously-created categories which don't specify a scope_id Category.where(:scope_id => nil).update_all(:scope_id => Control::CATEGORY_TYPE_ID) end def down end end
Ruby
class FixResponsesWithoutPopSamples < ActiveRecord::Migration def up end def down end end
Ruby
class AddTypeToRiskyAttributes < ActiveRecord::Migration def change change_table :risky_attributes do |t| t.string :type_string end end end
Ruby
class CreateRiskRiskyAttributes < ActiveRecord::Migration def change create_table :risk_risky_attributes do |t| t.references :risk, :null => false t.references :risky_attribute, :null => false t.references :modified_by t.timestamps end end end
Ruby
class DeleteReferencesWithoutUrLs < ActiveRecord::Migration def up Document.where(:link => nil).concat(Document.where(:link => "")).each {|x| x.destroy} end def down end end
Ruby
class AddNetworkZoneIdToSystems < ActiveRecord::Migration def change add_column :systems, :network_zone_id, :integer end end
Ruby
class AddUrlToSections < ActiveRecord::Migration def change add_column :sections, :url, :string end end
Ruby
class AddProgramColumns < ActiveRecord::Migration def up change_table :programs do |t| t.string :version t.datetime :start_date t.datetime :stop_date t.string :url t.string :organization t.text :scope t.references :kind t.datetime :audit_start_date t.reference...
Ruby
class AddNaToSection < ActiveRecord::Migration def change add_column :sections, :na, :boolean, :null => false, :default => false add_column :sections, :notes, :text end end
Ruby
class FixResponsesWithoutPopSamples2 < ActiveRecord::Migration def up transaction do Response .joins( :request ) .where( :requests => { :type_id => 2 } ) .joins("left outer join population_samples as population_sample on population_sample.response_id = responses.id") .where(:popu...
Ruby
class RemoveRiskFields < ActiveRecord::Migration def up remove_column :risks, :financial_impact remove_column :risks, :reputational_impact remove_column :risks, :operational_impact end def down end end
Ruby
class UpdateLanguagesAndControlKinds < ActiveRecord::Migration def up o = Option.where(:role => 'control_kind', :title => 'Directive').first if o o.title = 'Administrative' o.save end o = Option.where(:role => 'control_means', :title => 'Manual with Segregation of Duties').first if o ...
Ruby
class AddPopulationSampleForExistingResponses < ActiveRecord::Migration def up Request.all. select { |r| r.type_name == 'Population Sample' }. map { |r| r.responses.all }. flatten. each { |r| r.create_population_sample if r.population_sample.nil? } end def down end end
Ruby
class AddRiskFields < ActiveRecord::Migration def change add_column :risks, :inherent_risk, :text add_column :risks, :risk_mitigation, :text add_column :risks, :residual_risk, :text add_column :risks, :impact, :text end end
Ruby
class CreateCategories < ActiveRecord::Migration def change create_table :categories do |t| t.string :name t.integer :parent_id t.integer :lft t.integer :rgt t.integer :scope_id t.integer :depth t.timestamps end create_table :categorizations do |t| t.refer...
Ruby
class RemovePbcListsColumns < ActiveRecord::Migration def up change_table :pbc_lists do |t| t.remove :title t.remove :description t.remove :audit_firm t.remove :audit_lead t.remove :notes t.remove :list_import_date t.remove :status end end def down end end
Ruby
class CopyBizProcessesToSystems < ActiveRecord::Migration class BizProcess < ActiveRecord::Base end def up System.reset_column_information # Copy BizProcess and relations to System BizProcess.all.each do |bp| sys = System.create!( :title => bp.title, :slug => bp.slug, :...
Ruby
class FixCategories < ActiveRecord::Migration def change change_table :categorizations do |t| t.belongs_to :modified_by end rename_column :categorizations, :stuff_id, :categorizable_id rename_column :categorizations, :stuff_type, :categorizable_type change_table :categories do |t| t.b...
Ruby
class SetProgramIdOnCycles < ActiveRecord::Migration def up transaction do Cycle.all.each do |cycle| directive = Directive.find(cycle.directive_id) program = directive.programs.first cycle.update_attribute(:program_id, program.id) end end end def down end end
Ruby
class CreateMeetings < ActiveRecord::Migration def change create_table :meetings do |t| t.references :response t.datetime :start_at t.string :calendar_url t.references :modified_by t.timestamps end end end
Ruby
class CreateSystemSystems < ActiveRecord::Migration def change create_table :system_systems do |t| t.references :parent, :null => false t.references :child, :null => false t.string :type t.integer :order t.references :modified_by t.timestamps end end end
Ruby
class UpdateAccountRoles < ActiveRecord::Migration def up Account.where(:role => 'superuser').each do |account| account.role = 'admin' account.save end end def down end end
Ruby
class RenameLocationsToFacilities < ActiveRecord::Migration RELATIONSHIP_TYPE_NAME_CHANGES = [ ["location_has_process", "facility_has_process"], ["location_has_risky_attribute", "facility_has_risky_attribute"], ["location_is_dependent_on_location", "facility_is_dependent_on_faci...
Ruby