Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Ricardo Otero rikas

🏠
Working from home
View GitHub Profile
@rikas
rikas / record.rb
Created Feb 12, 2020
Record to be used like the ActiveRecord::Base class
View record.rb
# 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 / Counter.css
Created Sep 18, 2019
React counter styles
View Counter.css
.counter {
  padding: 50px;
  width: 200px;
  margin: auto;
  display: flex;
  align-items: center;
}
.counter button {
  font-size: 2em;
@rikas
rikas / App.css
Last active Dec 12, 2019
Giphy Styles
View App.css
#root > div {
display: flex;
height: 100vh;
}
.left-scene {
flex: 0 0 60%;
position: sticky;
display: flex;
flex-direction: column;
View controller.rb
# controller.rb
require_relative 'view'
require_relative 'task'
class Controller
def initialize(repository)
@repo = repository
@view = View.new
end
@rikas
rikas / chef.rb
Created Apr 18, 2019
OOP Advanced — Batch 243
View chef.rb
# 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 Apr 17, 2019
Livecode Basic OOP - 243
View citizen.rb
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 Apr 17, 2019
OOP Basics — Batch 243
View car.rb
# 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 / methods.rb
Created Jan 15, 2019
Programming basics — batch 224
View methods.rb
# methods.rb
# method names should be snake_cased
# no arguments
def random_method
return 10
end
# puts random_method
@rikas
rikas / chef.rb
Created Oct 25, 2018
Advanced OOP lecture
View chef.rb
# chef.rb
class Chef
attr_reader :name, :restaurant
def initialize(name, restaurant)
@name = name # String instance
@restaurant = restaurant # Restaurant instance
end
end
@rikas
rikas / car.rb
Created Oct 24, 2018
OOP Basics Lecture
View car.rb
# car.rb
# filename - lower_snake_case
# class name - UpperCamelCase
# sports_car.rb => SportsCar
class Car
attr_reader :brand
# attr_writer :color
You can’t perform that action at this time.