- login to 'AWS Management Console' (https://aws.amazon.com/console/)
- from 'Services'(in navbar) choose 'EC2'
- from 'Create Instance' section, click on 'Launch Instance'
- then select 'AMI' (Amazon Machine Image), we will be using 'Ubuntu Server 16.04 LTS (HVM)' as example
- select 'Instance Type' as per your requirement
- then click 'Next:Configure Instance Details' to continue
change 'Configure Instance Details' or used as default settings
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 Robot | |
MOVEMENTS = ['N', 'E', 'W', 'S'] | |
ACTIONS = ['G', 'D'] | |
CRATES_POSITIONS = [] | |
@length = 10 | |
@width = 10 | |
@is_lifting = false |
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
# Clean backslash characters | |
def clean_str(str) | |
new_str = [] | |
str.chars.each do |char| | |
if char == "\\" | |
next | |
end | |
new_str << char | |
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
def filter | |
# receive params | |
allowed_constant_params = %w(property_type listing_type_id rooms bathrooms location) | |
allowed_varying_params = %w(price) | |
query = "" | |
allowed_constant_params.each do |param| | |
unless params[param] == "" | |
if query.empty? | |
query.concat("SELECT * FROM properties WHERE #{param} = '#{params[param]}'") |
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
function validateEmail(email) { | |
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
if (email.match(re)) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
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
var phoneno = /^(07)([0-9|7])(\d){7}$/; | |
if (phonenumber.match(phoneno)) { | |
return true; | |
} else { | |
return false; | |
} |