Skip to content

Instantly share code, notes, and snippets.

View rodloboz's full-sized avatar

Rui Freitas rodloboz

View GitHub Profile
@rodloboz
rodloboz / mistral.livemd
Created April 16, 2025 09:09
Mistral Livebook

Mistral

Mix.install([
  {:mistral, "~> 0.3.0"},
  {:anthropix, "~> 0.6"},
  {:kino, "~> 0.15.0"},
])
@rodloboz
rodloboz / hello.rb
Created February 10, 2023 10:41
Ruby Hello World
def hello(name = "world")
"Hello, #{name}!"
end
@rodloboz
rodloboz / Dockerfile
Created November 25, 2022 14:53 — forked from erdostom/Dockerfile
Good starter Dockerfile + docker-compose.yml for Rails 6.
FROM ruby:2.6.5-alpine
RUN apk add --update --no-cache bash build-base nodejs sqlite-dev tzdata postgresql-dev yarn
RUN gem install bundler:2.1.4
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install --check-files
@rodloboz
rodloboz / app.rb
Created August 14, 2020 08:01
SQL CRUD
# Gem/Library to allow Ruby to interact with the DB
require 'sqlite3'
require 'byebug'
require_relative 'doctor'
# Create a DB connection
DB = SQLite3::Database.new("doctors.db")
#[[1, "John Smith", 39, "Anesthesiologist"], [2, "Emma Reale", 31, "Cardiologist"]]
@rodloboz
rodloboz / app.rb
Created August 13, 2020 15:42
LIVECODE SQL Day One
DB = "connection to the DB"
def find_tracks_by_genre(genre_name)
query = <<SQL
SELECT tracks.name, tracks.composer
FROM tracks
JOIN playlist_tracks ON playlist_tracks.track_id = tracks.id
JOIN playlists ON playlist_tracks.playlist_id = playlists.id
WHERE playlists.name = '#{genre_name}';
SQL
@rodloboz
rodloboz / sql_queries.sql
Last active July 28, 2022 13:38
SQL Queries
-- GIVE ALL THE PATIENT NAMES
SELECT first_name, last_name FROM patients;
-- GIVE ALL THE DOCTOR NAMES
SELECT first_name, last_name FROM doctors;
-- GIVE ME ALL YOU GOT ON PATIENTS
SELECT * FROM patients;
-- GIVE ME ALL THE PATIENTS AGED 21
@rodloboz
rodloboz / app.rb
Created August 7, 2020 08:24
MVC Intro - TODO App
require_relative "task"
require_relative "task_repository"
require_relative "tasks_controller"
require_relative "router"
require "byebug"
# Create an instance of TaskRepository
task_repository = TaskRepository.new
@rodloboz
rodloboz / car.rb
Created August 5, 2020 08:08
Car Class
# color, brand, speed
# Class names are in UpperCamelCase
# Open a class statement
class Car
attr_reader :brand, :license_plate # Creates GETTERS
# attr_writer :color # Creates SETTERS
attr_accessor :color # Creates GETTERS and SETTERS
@rodloboz
rodloboz / acronymize.rb
Created July 29, 2020 15:45
Acronymize solution
# CEO - Chief Executive Officer
# ASAP - as soon as possible
# DIY - DO IT YOURSELF
def acronymize(sentence)
# sentence.upcase.split.map(&:chr).join
@rodloboz
rodloboz / price.rb
Created July 28, 2020 15:55
Livecode - Day 1
# Write a game where the player has to guess a
# random price between 1 and 100 chosen by the program.
# The program should keep asking until the player
# guesses the right price.
# When the guess is right, the program displays how
# many guesses it took the player to win.
# generate random price between 1 and 100
# ask the player for a number (between 1 to 100)
# store attempt number