Skip to content

Instantly share code, notes, and snippets.

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

Teddy Paz Muñoz pazteddy

🏠
Working from home
View GitHub Profile
@pazteddy
pazteddy / todo_list.rb
Last active May 26, 2023 22:39
Aplicación de lista de tareas (ToDo List) implementada en Ruby. Permite al usuario administrar y realizar un seguimiento de diferentes tareas. La clase TodoList proporciona métodos para agregar tareas a la lista, marcar tareas como completadas, desmarcarlas y muestra la lista de tareas con información sobre el estado de cada tarea.
class TodoList
attr_accessor :items
def initialize
@items = []
end
def add_item(description)
@items << { description: description, completed: false }
end
@pazteddy
pazteddy / keepable.rb
Last active May 31, 2023 23:07
Wokshop Keepable - Notes and Trash Pages
def notes_page
puts "Tabla de las notas"
action = ""
until action == "logout"
action = get_with_options(["create", "update", "delete", "toggle", "trash", "logout"])
case action
when "create" then puts "Create note action"
when "update" then puts "Update note action"
when "delete" then puts "Delete note action"
when "toggle" then puts "Toggle note action"
@pazteddy
pazteddy / portafolio.html
Created June 5, 2023 01:45
Este código proporciona una estructura HTML básica y estilos CSS para crear un portafolio de programador con información sobre el programador, sus proyectos, servicios ofrecidos y detalles de contacto
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Portafolio de Programador</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;700&display=swap" rel="stylesheet">
<style>
@pazteddy
pazteddy / animations.html
Created June 14, 2023 14:04
Template for practice CSS animations
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Transitions</title>
<link rel="stylesheet" href="/assets/css/style.css">
<style>
SELECT nombre_departamento, COUNT(*) AS total_empleados
FROM empleados JOIN departamento ON departamento.id_departamento = empleados.id_departamento
GROUP BY nombre_departamento;
@pazteddy
pazteddy / booking.rb
Created June 22, 2023 03:04
Code snippets collection for the project SQL Booking
def print_welcome
puts "Welcome to Booking"
puts "Write 'menu' at any moment to print the menu again and 'exit' to quit"
end
def print_menu
puts "---"
puts "1. Top 5 publisher by annual revenue"
puts "2. Search books by [title=string | author=string | publisher=string]"
puts "3. Count books by [author | publisher | genre]"
@pazteddy
pazteddy / presenter.rb
Created June 25, 2023 23:37
Code snippets for clivia generator
module Presenter
def print_welcome
# print the welcome message
puts ["###################################",
"# Welcome to Clivia Generator #",
"###################################"].join("\n")
end
def print_score(score)
puts "Well done! Your score is #{score}"
@pazteddy
pazteddy / cheatsheet_week3.md
Created July 12, 2023 01:24
Associations, callbacks and validations

Associations

Task 1. Create models and tables

rails generate model User username email role critics_count:integer
rails g model Critic title body:text user:references
rails g model Company name description:text start_date:date country cover
rails g model Game name summary:text release_date:date category:integer rating:decimal cover
rails g model Platform name category:integer
@pazteddy
pazteddy / seed.rb
Created July 12, 2023 01:37
Generate seeds for the critics alpha app
require "json"
companies_data = JSON.parse(File.read("db/data/companies.json"))
games_data = JSON.parse(File.read("db/data/games.json"))
genres_data = JSON.parse(File.read("db/data/genres.json"))
platforms_data = JSON.parse(File.read("db/data/platforms.json"))
puts "Start seeding"
Company.destroy_all
@pazteddy
pazteddy / application.html.erb
Last active July 13, 2023 17:41
Snippets of code to develop a little faster the Offix workshop
<body>
<header>
<div class="container">
<div class="header navbar">
<%=link_to image_tag("/images/logo.png"), departments_path%>
<%=form_with url: "/search", method: :get do |f|%>
<%=f.label :consulta, "Search employees: " %>
<%=f.text_field :consulta %>
<%end%>
</div>