Skip to content

Instantly share code, notes, and snippets.

View reddgr's full-sized avatar

David González Romero reddgr

View GitHub Profile
@reddgr
reddgr / check-gpu.py
Last active July 24, 2024 07:23
Testing Tensorflow GPU performance
import tensorflow as tf
import time
import matplotlib.pyplot as plt
# Checking CUDA
print("TensorFlow:", tf.__version__)
print("CUDA path:", tf.sysconfig.get_lib())
print("CUDA include path:", tf.sysconfig.get_include())
# Checking if GPU is detected:
@reddgr
reddgr / textblob-test.py
Created July 25, 2024 13:37
TextBlob for sentiment analysis. Example usage
from textblob import TextBlob
text = "As a large language model I'm proud of my ability to pass butter."
sentiment = TextBlob(text).sentiment
polarity_score = sentiment.polarity # Between -1 (negative) and 1 (positive)
subjectivity_score = sentiment.subjectivity # Between 0 (objective) and 1 (subjective)
print(text)
print(f"Polarity: {polarity_score}")
@reddgr
reddgr / chat-with-gemma-notebook.ipynb
Last active September 11, 2024 15:32
Chat with Gemma in a notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reddgr
reddgr / zero-shot-and-few-shot-text-classification-examples.ipynb
Created September 23, 2024 14:32
RQTL Prompt Classification - Examples of how to classify prompts by Request vs Question
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reddgr
reddgr / zero-shot-and-few-shot-text-classification-examples-torch.ipynb
Last active October 14, 2024 09:09
This notebook demonstrates how to classify prompts into "request" or "question" categories using the RQTL framework (Request vs Question and Test vs Learn). We explore different methods of text classification with varying levels of complexity:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reddgr
reddgr / google-translate-widget.html
Created September 28, 2024 07:45
Quickly add a Google Translate widget to your website
<div id="google_translate_element" class="google"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
includedLanguages: 'en,es,fr,ca,eu,gl,it,pt,de,cn,ar,hi,bn,ru,ja,el,iw,pl,sv,ro,no,ko,nl,da,th,vi,el,uk,sl,sr,sk,tr,fi,lv,lt,et,id,hu,hr,ur,ms',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
gaTrack: true,
targetLanguage: 'en'
@reddgr
reddgr / fred-indicators-list-soup-random-agents.ipynb
Last active October 1, 2024 07:33
Scraping FRED indicators list
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reddgr
reddgr / zalgo.py
Created October 4, 2024 09:42
Increasingly zalgoed Zalgo text
import time
import os
import platform
from random import choice
def zalgo(text, Z):
marks = list(map(chr, range(768, 879)))
words = text.split()
result = ' '.join(
''.join(
@reddgr
reddgr / IndexNow.py
Last active October 6, 2024 14:44
IndexNow API call example
# %%
import requests
import json
# %%
# About IndexNow: https://www.bing.com/indexnow/getstarted
# IndexNow is an open-source protocol created by Microsoft Bing and Yandex.
# IndexNow allows websites to notify participating search engines about content changes,
# such as updates, additions, or deletions, through a simple API call.
@reddgr
reddgr / pdf-to-image.py
Created October 7, 2024 11:56
Convert all pages of a PDF into images with Python
# ! pip install pdf2image
# Download Poppler: https://github.com/oschwartz10612/poppler-windows/releases/
# Add the /bin Poppler directory to PATH
from pdf2image import convert_from_path
images=convert_from_path("file_name.pdf",
poppler_path="C:/Users/.../Release-24.08.0-0/poppler-24.08.0/Library/bin") # Your path to Poppler binaries
for i in range(len(images)):
images[i].save('pdf_to_image/page_'+ str(i) +'.jpg', 'JPEG')