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 / alpha_vantage.ipynb
Last active October 24, 2024 20:40
Alpha Vantage API essentials (Python)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reddgr
reddgr / list-wp-child-pages.php
Last active October 14, 2024 12:09
Shortcode to display all child pages of a given Wordpress directory
// Shortcode to display child pages (add this to functions.php)
function list_child_pages($atts) {
$atts = shortcode_atts(array(
'parent_id' => 0,
), $atts, 'child-pages');
$args = array(
'post_type' => 'page',
'post_parent' => $atts['parent_id'],
'orderby' => 'menu_order',
@reddgr
reddgr / wp-bulk-html-upload.sh
Created October 13, 2024 23:43
Creates Wordpress pages in bulk from HTML files
#!/bin/bash
# Path to the directory containing our HTML files
HTML_DIR="$HOME/wordpress/wp-content/uploads/grok"
# Loop through all HTML files in the directory
for html_file in "$HTML_DIR"/*.html; do
# Extract the file name without the extension
file_name=$(basename "$html_file" .html)
@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')
@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 / 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 / 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 / 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 / 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 / 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.