Skip to content

Instantly share code, notes, and snippets.

@markeban
markeban / cloudSettings
Created October 25, 2018 15:48
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-10-25T15:48:34.441Z","extensionVersion":"v3.2.0"}
a = "Masha"
b = "Antonovich"
c = "37"
puts "Your name is " + a + " " + b + " and you are " + c + " years old."
my_favorite_number = 9
your_favorite_number = 1
my_favorite_number + your_favorite_number = both
puts both
first_number = 3
puts first_number + second_number
@markeban
markeban / pi.rb
Created April 11, 2016 21:45
What's wrong with the code below?
puts 3
puts 1
put 4
puts 1
puts 5
puts 9
@markeban
markeban / index.json.jbuilder
Last active December 12, 2015 22:49
Force 6 digit zipcodes
json.addresses @employee.addresses do |address|
if address.zip.length > 5
json.line_1 address.line_1
json.line_2 address.line_2
json.city address.city
json.state address.state
json.zip address.zip
end
end
@markeban
markeban / seeds.rb
Last active August 29, 2015 14:23
Employee info + addresses seed file
100.times do
Employee.create(
:first_name => Faker::Name.first_name,
:last_name => Faker::Name.last_name,
:email => Faker::Internet.email,
:birthdate => Faker::Date.backward(50000),
:ssn => Faker::Code.ean,
)
end
@markeban
markeban / person.rb
Created September 23, 2014 23:45
Getters
class Person
attr_reader :age, :job, :mood
def initialize(initial_age = "31", initial_job = "teacher", initial_mood = "content")
@age = initial_age
@job = initial_job
@mood = initial_mood
@markeban
markeban / person.rb
Created September 23, 2014 23:33
Instance Variables
class Person
def age
puts "How old are you?"
@age = gets.chomp
return @age
end
def job
puts "What's your occupation?"
@markeban
markeban / person.rb
Created September 23, 2014 23:31
Constructors
class Person
def initialize(initial_age = "31", initial_job = "teacher", initial_mood = "content")
@age = initial_age
@job = initial_job
@mood = initial_mood
puts "You must be #{@age} years old, work as a #{@job} and currently feel #{@mood} unless you've specified otherwise."
end