Skip to content

Instantly share code, notes, and snippets.

@martingaido
martingaido / biorhythm.py
Created December 3, 2022 20:19
Script to calculate your biorhythm
from datetime import datetime, timedelta
import math
def calculate_biorhythm(birthday, current_date, rhythm_type):
days_difference = (current_date - birthday).days
if rhythm_type == 'physical':
cycle = 23
elif rhythm_type == 'emotional':
/*
Hamming distance is a measure of the difference between
two same-length strings of characters. Simply put, it is
defined as the number of positions at which corresponding
characters in two strings of characters are different.
Formally, the Hamming distance between two same-length
strings of characters, s and t, is defined as the number
of positions at which the corresponding characters are
@martingaido
martingaido / termGPT.sh
Created March 6, 2023 23:14
TerminalGPT
#!/bin/bash
# Replace YOUR_API_KEY with your actual API key
API_KEY="OPEN_AI_API_KEY"
# Get the message from the command line argument
MESSAGE=$1
# Set up the API endpoint
API_ENDPOINT="https://api.openai.com/v1/chat/completions"
@martingaido
martingaido / xmenu.sh
Created March 6, 2023 23:28
Menu Interactivo en BASH
#!/bin/bash
# Define las opciones del menú
options=("Opción 1" "Opción 2" "Opción 3" "Salir")
# Establece la posición inicial del cursor en la primera opción
selected=0
# Función para mostrar el menú y resaltar la opción seleccionada
function show_menu() {
@martingaido
martingaido / sitemap.py
Created May 25, 2023 20:16
Python script to create sitemap.xml
import requests
from bs4 import BeautifulSoup
from urllib.parse import urlparse, urljoin
def create_sitemap(url):
# Parse the base URL
parsed_url = urlparse(url)
base_url = parsed_url.scheme + "://" + parsed_url.netloc
# Initialize the set of visited URLs
@martingaido
martingaido / shellCodeValidator.sh
Last active July 20, 2023 23:48
Code Validation for Terminal (bash) using ChatGPT-4
#!/bin/bash
# Replace YOUR_API_KEY with your actual API key
API_KEY="OPEN_AI_API_KEY"
# Clear the screen
clear
# Function to check if the API key is set
check_api_key() {
@martingaido
martingaido / ollama-rag.py
Created December 23, 2023 20:58
RAG Ollama
from langchain.llms import Ollama
from langchain.document_loaders import WebBaseLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings import GPT4AllEmbeddings
from langchain.vectorstores import Chroma
from langchain.chains import RetrievalQA
import gradio as gr
# Initialize variables to store the previous URL and its corresponding data and embeddings
prev_url = None