Skip to content

Instantly share code, notes, and snippets.

View rikas's full-sized avatar
🏠
Working from home

Ricardo Otero rikas

🏠
Working from home
View GitHub Profile
@rikas
rikas / methods.rb
Created January 15, 2019 10:43
Programming basics — batch 224
# methods.rb
# method names should be snake_cased
# no arguments
def random_method
return 10
end
# puts random_method
@rikas
rikas / basics.rb
Created January 12, 2021 11:38
Programming basics
"Ricardo" #=> String
4 #=> Integer
4.6 #=> Float
[1,2,3] #=> Array
(1..10) #=> Range
false #=> FalseClass (Boolean)
true #=> TrueClass (Boolean)
nil #=> NilClass
@rikas
rikas / Counter.css
Created September 18, 2019 20:52
React counter styles
.counter {
  padding: 50px;
  width: 200px;
  margin: auto;
  display: flex;
  align-items: center;
}
.counter button {
  font-size: 2em;
@rikas
rikas / record.rb
Created February 12, 2020 19:58
Record to be used like the ActiveRecord::Base class
# You can use a global variable, DB, which
# is an instance of SQLite3::Database
# NO NEED TO CREATE IT, JUST USE IT.
require 'sqlite3'
require 'pry-byebug'
db_file_path = File.join(File.dirname(__FILE__), "../../spec/support/posts_spec.db")
DB = SQLite3::Database.new(db_file_path)
DB.results_as_hash = true
@rikas
rikas / App.css
Last active December 12, 2019 02:34
Giphy Styles
#root > div {
display: flex;
height: 100vh;
}
.left-scene {
flex: 0 0 60%;
position: sticky;
display: flex;
flex-direction: column;
# controller.rb
require_relative 'view'
require_relative 'task'
class Controller
def initialize(repository)
@repo = repository
@view = View.new
end
@rikas
rikas / chef.rb
Created April 18, 2019 11:03
OOP Advanced — Batch 243
# chef.rb
class Chef
attr_reader :name, :restaurant
def initialize(name, restaurant)
@name = name # String instance
@restaurant = restaurant # Restaurant instance
end
end
@rikas
rikas / citizen.rb
Created April 17, 2019 18:31
Livecode Basic OOP - 243
class Citizen
# attr_reader :first_name, :last_name, :age
attr_reader :age, :height
def initialize(first_name, last_name)
@first_name = first_name
@last_name = last_name
@age = 0
@height = rand(10..40)
@alive = true
@rikas
rikas / car.rb
Created April 17, 2019 15:36
OOP Basics — Batch 243
# car.rb
class Car
# attr_reader :color, :brand
attr_reader :brand
# attr_writer :color
attr_accessor :color
# initializer or constructor
def initialize(color, brand)
@rikas
rikas / chef.rb
Created October 25, 2018 10:09
Advanced OOP lecture
# chef.rb
class Chef
attr_reader :name, :restaurant
def initialize(name, restaurant)
@name = name # String instance
@restaurant = restaurant # Restaurant instance
end
end