Skip to content

Instantly share code, notes, and snippets.

View rodloboz's full-sized avatar

Rui Freitas rodloboz

View GitHub Profile
@rodloboz
rodloboz / date.rb
Created July 28, 2020 08:59
01-Ruby/01-Programming Basics
require 'date'
# A method that receives two integers
# and returns the one that's greater
def max(x, y)
# compare x with y
# if x is greater
if x > y
# return x
@rodloboz
rodloboz / parset_int.rb
Last active February 26, 2020 16:49
Parse Int
NUMERALS_MAP = {
'zero' => 0,
'one' => 1,
'two' => 2,
'three' => 3,
'four' => 4,
'five' => 5,
'six' => 6,
'seven' => 7,
'eight' => 8,
class Record
def initialize(attributes)
initialize_accessors
assign_attributes(attributes)
end
def self.attr_accessor(*vars)
@attributes ||= []
@attributes.concat vars
super(*vars)

Lecture Notes:

Your're going to code a solution to the TODO list during livecode so no lecture code today 😢

Here are a few takeways and snipplets from the lecture:

SELECTING HTML ELEMENTS:

document.querySelector(CSS_SELECTOR), where CSS_SELECTOR is any valid css selector that you use in css files. Similar to Ruby's find, it returns an element (returns 1 thing only).

@rodloboz
rodloboz / 01_types.js
Created February 9, 2020 23:16
JS Basics
console.log('Hello, world!')
"Hello" // String
'Hello' // String
3 // Number
@rodloboz
rodloboz / doctor.rb
Last active January 30, 2020 23:01
SQL CRUD Lecture Code
# Our Model will have to "talk" to the DB
# It will send SQL queries
# DB - we have access to this constant
class Doctor
attr_reader :id, :name, :age, :specialty
def initialize(attributes = {})
@id = attributes[:id]
@rodloboz
rodloboz / db_queries.sql
Created January 29, 2020 22:52
SQL queries
-- GIVE ME ALL PATIENT NAMES
SELECT first_name, last_name FROM patients;
-- GIVE ME ALL FIELDS FROM PATIENTS
SELECT * FROM patients;
-- GIVE ME ALL DOCTOR NAMES
SELECT first_name, last_name FROM doctors;
-- GIVE ME ALL ABOUT DOCTORS []
require 'open-uri'
require 'nokogiri'
require 'byebug'
class Book
# {
# cover: "goodread.com...",
# title: "For Whom the Bell Tolls",
# author: "Ernest Hemmingway",
# rating: 4.56
@rodloboz
rodloboz / app.rb
Created January 22, 2020 23:19
Advanced OOP Lesson
require 'byebug'
require_relative 'boat'
require_relative 'canoe'
require_relative 'motorboat'
require_relative 'sailboat'
puts "------------ Advanced OOP: Gone Fishin' ------------"
@rodloboz
rodloboz / car.rb
Created January 21, 2020 22:31
Introduction to OOP
# opening a class statement
class Car
# Getter / Reader
# attr_reader :color # => defines a getter
# attr_writer :color # => defines a setter
attr_accessor :color # => defines both
# This is the constructor
# will be called on .new