Skip to content

Instantly share code, notes, and snippets.

View truevis's full-sized avatar
💭
Hacking existence

Eric B truevis

💭
Hacking existence
View GitHub Profile
@truevis
truevis / add_github_collaborator.bat
Created July 9, 2025 12:38
GitHub Bulk Collaborator Management Script A Windows batch script that allows you to add collaborators to multiple GitHub repositories
@echo off
setlocal enabledelayedexpansion
REM ===================================================================
REM GitHub Bulk Collaborator Management Script
REM ===================================================================
REM This script adds a collaborator to multiple GitHub repositories
REM in bulk using the GitHub CLI (gh).
REM
REM Prerequisites:
@truevis
truevis / ftp_changed_pages.py
Created June 18, 2025 08:53
Upload new changed files to FTP
import os
import ftplib
import json
from datetime import datetime, date
import fnmatch
# Import FTP credentials from configuration file
from ftp_config import FTP_HOST, FTP_USER, FTP_PASS
# --- Local Configuration ---
import os
import base64
import json
import time
from pathlib import Path
from mistralai import Mistral
from typing import Optional
# API key - directly defined
api_key = "YO123"
@truevis
truevis / looks_like_nec_page
Created March 6, 2025 09:39
Validate text using Gemini and output true or false in JSON
model = "gemini-2.0-pro-exp-02-05"
# Set API key
GEMINI_API_KEY = "abc"
def log_failed_validation(pdf_path):
"""Log failed validation to failed.log with timestamp"""
if pdf_path:
base_name = os.path.splitext(os.path.basename(pdf_path))[0]
timestamp = datetime.now().isoformat()
with open('failed.log', 'a') as f:
@truevis
truevis / pytube_import_YouTube_to_mp3.py
Last active April 30, 2024 19:36
Downloads and saves YouTube audio streams using pytube
import re
from pytube import YouTube
def download_youtube_audio(url):
yt = YouTube(url)
audio_stream = yt.streams.filter(only_audio=True).first()
# Remove invalid characters from the filename using regex
cleaned_title = re.sub(r'[<>:"/\\|?*]', '_', yt.title)
@truevis
truevis / streamlit_chat_groq_memory.py
Last active April 24, 2024 11:27
Groq API chatbot using Llama3
import streamlit as st
from langchain_groq import ChatGroq
from langchain_core.prompts import ChatPromptTemplate
def generate_response(user_input):
chain = prompt | chat
for chunk in chain.stream({"text": "\n".join([f"{role}: {msg}" for role, msg in st.session_state.messages])}):
content = chunk.content
#replace $ in content so no latex
content = content.replace("$", "\\$")
@truevis
truevis / groq_llama3_streamlit.py
Last active April 24, 2024 08:19
Basic Groq API Response Streaming using Llama3
import streamlit as st
from groq import Groq
# Initialize Groq client with API key
client = Groq(api_key="gsk_123")
def generate_response(user_input):
stream = client.chat.completions.create(
model="llama3-70b-8192",
messages=[
@truevis
truevis / groq_llama3.py
Last active April 20, 2024 07:24
This script deftly enlists the Groq client to choreograph a dance with the llama3-70b-8192 model, playing out a skit where it conjures up an email about the thrilling world of government contract bidding in NY, sans the fluffy pleasantries.
from groq import Groq
# Initialize Groq client with API key
client = Groq(api_key="gsk_123")
completion = client.chat.completions.create(
model="llama3-70b-8192",
messages=[
{
"role": "system",
import os
from llama_parse import LlamaParse # pip install llama-parse
from llama_index.core import SimpleDirectoryReader # pip install llama-index
source_directory = r'\data'
target_directory = r'\tables'
parser = LlamaParse(
api_key="...", # can also be set in your env as LLAMA_CLOUD_API_KEY
result_type="markdown", # "markdown" and "text" are available
@truevis
truevis / generate_content_with_gemini.py
Last active January 5, 2024 21:20
This Python script uses 'gemini-pro-vision', attempts to generate content based on a prompt, and retries up to four times if it fails. If it manages to scrape together anything resembling a response, it returns it, otherwise, it accepts defeat and returns an empty string
# Configure the API key
GOOGLE_API_KEY = "123"
genai.configure(api_key=GOOGLE_API_KEY)
# Load environment variables
GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY')
def generate_content_with_gemini(prompt):
model = genai.GenerativeModel('gemini-pro-vision')
text_content = ''
response = None # Initialize response to ensure it's in the proper scope