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 "nokogiri" | |
# 1) What is your favorite Ruby class/library or method and why? | |
# 2) Given HTML: "<div class="images"><img src="/pic.jpg"></div>" Using Nokogiri how would you select the src attribute from | |
# the image? Show me two different ways to do that correctly the HTML given. | |
html = Nokogiri::HTML('<div class="images"><img src="/pic.jpg"></div>') | |
w1 = html.css('img')[0]['src'] # => "/pic.jpg" | |
w2 = html.xpath('//img/@src') # => "/pic.jpg" |
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
# encoding: cp866 | |
money = 100 | |
puts "\nЯ вижу у тебя есть #{money}$ и тебе не терпится их проиграть? Ну что же, начнём!" | |
1000.times do | |
puts |
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
def start | |
@num = rand (1..100) | |
print "Enter attempts number: " | |
@attempts = gets.to_i | |
print "Guess the number, #{@attempts} attempts, " |
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
print "Сколько вам лет? " | |
age = gets.to_i | |
print "Хотите играть? (Y/N) " | |
answer = gets.strip.capitalize | |
if answer == "Y" && age >= 18 | |
puts "Хорошо, поиграем!" | |
money = 100 |
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
print "How old are you? " | |
age = gets.to_i | |
print "Continue? (Y/N) " | |
answer = gets.strip.capitalize | |
if answer == "Y" && age >= 18 | |
puts "Ok, let's play!" | |
money = 100 |
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
print "(R)ock, (S)cissors, (P)aper? " | |
s = gets.strip.capitalize | |
if s == "R" | |
user_choice = :rock | |
elsif s == "S" | |
user_choice = :scissors | |
elsif s == "P" | |
user_choice = :paper | |
else |
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
options = [:paper, :rock, :scissors] | |
player1 = "" | |
player2 = "" | |
loop do | |
p1 = rand(0..2) | |
p2 = rand(0..2) | |
puts "Player 1: #{options[p1]}, Player 2: #{options[p2]}" |
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
git push heroku master | |
Total 0 (delta 0), reused 0 (delta 0) | |
remote: Compressing source files... done. | |
remote: Building source: | |
remote: | |
remote: -----> Ruby app detected | |
remote: -----> Compiling Ruby/Rails | |
remote: -----> Using Ruby version: ruby-2.2.6 | |
remote: -----> Installing dependencies using bundler 1.13.7 | |
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment |
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
Counting objects: 14, done. | |
Delta compression using up to 2 threads. | |
Compressing objects: 100% (14/14), done. | |
Writing objects: 100% (14/14), 1.53 KiB | 0 bytes/s, done. | |
Total 14 (delta 9), reused 0 (delta 0) | |
remote: Compressing source files... done. | |
remote: Building source: | |
remote: | |
remote: -----> Ruby app detected | |
remote: -----> Compiling Ruby/Rails |
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
var userChoice = prompt("Do you choose rock, paper or scissors?"); | |
var computerChoice = Math.random(); | |
if (computerChoice < 0.34) { | |
computerChoice = "rock"; | |
} else if(computerChoice <= 0.67) { | |
computerChoice = "paper"; | |
} else { | |
computerChoice = "scissors"; | |
} console.log("Computer: " + computerChoice); |
OlderNewer