Skip to content

Instantly share code, notes, and snippets.

View AlvisonHunterArnuero's full-sized avatar
😀
Coding ? keepCoding : backToCoding

Alvison Hunter AlvisonHunterArnuero

😀
Coding ? keepCoding : backToCoding
View GitHub Profile
@AlvisonHunterArnuero
AlvisonHunterArnuero / calcular_propina.py
Last active May 28, 2024 05:58
Ayuda con una tarea de un amigo internauta en apuros para aprender Python
opcion_invalida = "Opción inválida. ¡Intente de nuevo!"
msg_despedida = "¡Muchas gracias! ¡Que tenga un buen día!"
porc_comunes = ["1.1", "2.2", "3.3", "4.4", "5.5"]
while True:
dar_propina = input("¿Desea dejar propina? ").lower()
if dar_propina not in ["si", "no"]:
print(opcion_invalida)
continue
elif dar_propina in ["no"]:
@AlvisonHunterArnuero
AlvisonHunterArnuero / utilityTypesExamples.ts
Created May 18, 2024 06:35
My set of Examples for Utility Types
/* -------- Partial utility type ---------- */
interface FrontendDeveloper {
name?: string;
country?: string;
languages?: string[];
}
type BackendDeveloper = Partial<FrontendDeveloper>;
@AlvisonHunterArnuero
AlvisonHunterArnuero / utils.py
Created April 25, 2024 17:51
Utils file for all of the integration test
from typing import List, Any
from tabulate import tabulate # type: ignore
from datetime import datetime
import uuid
def is_promo_day(str_date: str, order_promo_day: str) -> bool:
"""
Check if a given date falls on a promotional day.
Args:
@AlvisonHunterArnuero
AlvisonHunterArnuero / SQLQueries.vb
Last active April 25, 2024 17:54
SQL Query Strings for Test Integration
SELECT *,
(SELECT brand FROM order_items
JOIN products on order_items.product_uid = products.uid AND order_items.order_uid = orders.uid
ORDER BY order_items.quantity desc limit 1) AS popular_brand
FROM orders
SELECT * FROM orders
JOIN order_items ON orders.uid = order_items.order_uid
JOIN products on products.uid = order_items.product_uid
from typing import Any, KeysView
from decouple import config # type: ignore
import psycopg2 # type: ignore
import pymongo # type: ignore
from tabulate import tabulate # type: ignore
from utils import is_promo_day, unique_id, print_table
# Import schemas
from schemas import order_schema, order_items_schema
// 6 - Closest to Zero | https://www.codewars.com/kata/59887207635904314100007b
function closestToZero(arr) {
arr.sort((a, b) => a - b);
let closest = arr[0];
let distance = Math.abs(closest);
for (let num of arr) {
const currentDistance = Math.abs(num);
if (currentDistance <= distance) {
distance = currentDistance;
closest = num;
const sortGrades = lst => {
const grades = [
"VB", "V0", "V0+", "V1", "V2", "V3", "V4", "V5", "V6", "V7",
"V8", "V9", "V10", "V11", "V12", "V13", "V14", "V15", "V16", "V17"
];
const result = new Array(grades.length).fill(null);
if (lst.length === 0) {
return [];
}
// // 12 - Is it a letter? | https://www.codewars.com/kata/57a06b07cf1fa58b2b000252
const isItLetter = (c) => /[a-zA-Z]/.test(c);
console.log(isItLetter("a")); // true, `'a' is a letter`
console.log(isItLetter("1")); // false, `'1' is not a letter`
// 11 - Bouncing Ball | https://www.codewars.com/kata/5a40c250c5e284a76400008c
const bouncingBall = (initial, proportion) => {
let totalBounces = 0;
while (initial > 1) {
totalBounces++;
initial *= proportion;
}
return totalBounces;
}
// 8 - Is n divisible by | https://www.codewars.com/kata/558ee8415872565824000007
const isDivisible = (...args) => {
console.log(args);
if (args.length <= 1) {
return true;
}
if (args.length === 2) {
return Number.isInteger(args[0] / args[1]);
} else {