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
<div class="cards-container"> | |
<div class="card"> | |
<div class="card-image" style="background-image: url(<%= image_path("background.jpg") %>);"> | |
</div> | |
<div class="card-info"> | |
<p>Description</p> | |
<span>Technologies:</span> | |
<ul> | |
<li>Item</li> | |
<li>Item</li> |
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
// Your validation code will go in there. | |
// Write your validation functions, and bind events | |
// in a jQuery DOM ready callback | |
$(document).ready(function() { | |
var events = "blur keyup" | |
$(".form-control").on(events, function() { | |
var value = $(this).val(); | |
if (value === "") { | |
$(this).parent().removeClass('has-success').addClass('has-error'); |
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
age = 23 | |
# *Assign* the value 23 to my variable `age` | |
puts "a year as passed" | |
# *Re-assigning* the value of the variable `age` | |
age = age + 1 | |
# age += 1 | |
# Interpolating the variable `age` inside a string |
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
counter = 1 | |
#generate random number between 1-100 | |
price = rand(1..2) | |
puts "guess a number chump" | |
pick = gets.chomp.to_i | |
p pick | |
until pick == price | |
if pick < price | |
puts "A little higher! Try again" |
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
students = [ "Peter", "Mary", "George", "Emma" ] | |
student_ages = [ 24 , 25 , 22 , 20 ] | |
# - Peter is X years old | |
students.each_with_index do |name, index| | |
age = student_ages[index] | |
puts "#{name} is #{age} years old" | |
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
text = open('article.txt').read | |
#create hash | |
histogram = {} | |
words = text.split | |
special_chars = (" ".."@").to_a | |
special_chars << ":" |
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
# car.rb -> lower_snake_case | |
class Car # UpperCamelCase | |
attr_reader :engine_started, :brand | |
attr_accessor :colour | |
def initialize(colour, brand = "Mini") # constructor | |
@colour = colour | |
@engine_started = false | |
@brand = brand |
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 FacebookUser | |
# DATA (instance variables) | |
attr_reader :email, :friends, :photos | |
attr_accessor :first_name, :last_name | |
def initialize(email, password) # constructor | |
@email = email | |
@password = password | |
@first_name = "" | |
@last_name = "" |
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 Chef | |
attr_reader :name, :restaurant | |
def initialize(name, restaurant) | |
@name = name # String | |
@restaurant = restaurant # Restaurant | |
end | |
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
class Patient | |
attr_accessor :room, :id | |
attr_reader :name, :cured | |
def initialize(attributes = {}) | |
@id = attributes[:id] | |
@room = attributes[:room] # Instance of Room | |
@name = attributes[:name] | |
@cured = attributes[:cured] || false | |
end |
OlderNewer