This file contains hidden or 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
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer |
This file contains hidden or 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
hudson.util.IOException2: Slave JVM has not reported exit code. Is it still running? | |
at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:953) | |
at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:133) | |
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:711) | |
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696) | |
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) | |
at java.util.concurrent.FutureTask.run(FutureTask.java:166) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) | |
at java.lang.Thread.run(Thread.java:724) |
This file contains hidden or 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
# models/instrument.rb | |
class Instrument | |
attr_accessor :units | |
def initialize(status, units) | |
@status = status | |
@units = units | |
end | |
def turn_on |
This file contains hidden or 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
# models/hotel.rb | |
class Hotel | |
attr_accessor :floors | |
def initialize(num_floors, num_of_mc, num_of_sc, controller) | |
@floors = [] | |
num_floors.times{ @floors << Floor.new(num_of_mc, num_of_sc) } | |
controller.add_observer(self) | |
end |
This file contains hidden or 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
# models/floor.rb | |
class Floor | |
attr_accessor :main_corridors | |
attr_accessor :sub_corridors | |
def initialize(num_of_mc, num_of_sc) | |
@main_corridors = [] | |
@sub_corridors = [] | |
num_of_mc.times do | |
mc = Corridor.new |
This file contains hidden or 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
#models/corridor.rb | |
class Corridor | |
attr_accessor :lights | |
attr_accessor :air_conditioners | |
def initialize | |
@lights = [Instrument.new(STATUS_OFF, DEFAULT_UNITS_LIGHTS)] | |
@air_conditioners = [Instrument.new(STATUS_OFF, DEFAULT_UNITS_AC)] | |
@movement = false | |
end |
This file contains hidden or 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
#models/controller.rb | |
require 'observer' | |
class Controller | |
include Observable | |
attr_accessor :hotel | |
def initialize(num_floors, num_of_mc, num_of_sc) | |
@hotel = Hotel.new(num_floors, num_of_mc, num_of_sc, self) |
This file contains hidden or 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
#init/constants.rb | |
STATUS_OFF = 'OFF' | |
STATUS_ON = 'ON' | |
DEFAULT_UNITS_LIGHTS = 5 | |
DEFAULT_UNITS_AC = 10 |
This file contains hidden or 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
require 'pry' | |
Dir["./init/*.rb"].each {|file| require file } | |
Dir["./models/*.rb"].each {|file| require file } | |
print "Enter the number of Floors: " | |
floors = gets.chomp | |
print "Enter the number of Main Corridors: " | |
mc_per_floor = gets.chomp | |
print "Enter the number of Sub Corridors: " | |
sc_per_floor = gets.chomp |
This file contains hidden or 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
#Usage: cap production db:load_from_remote | |
namespace :db do | |
desc "Clones the dump from Production and loads to local database" | |
task :load_from_remote do | |
on roles(:app) do | |
within current_path do | |
with rails_env: fetch(:rails_env) do | |
execute 'pg_dump --format=c mydb_production > /var/apps/my_project/shared/prod_db.dump' | |
end |