Skip to content

Instantly share code, notes, and snippets.

View ruphy's full-sized avatar
magic

Riccardo Iaconelli ruphy

magic
View GitHub Profile
@ruphy
ruphy / handler.py
Created March 2, 2025 10:52
VTT to TXT parser (serverless)
import re
import json
def convert_vtt_to_txt(raw_text):
# Improved regex to handle closing tags properly
pattern = re.compile(r"<v ([^>]+)>(.+?)</v>", re.DOTALL)
matches = pattern.findall(raw_text)
# Clean up whitespaces in dialogues
structured_lines = [
@ruphy
ruphy / token
Created March 2, 2025 10:35
CLI utility for estimating tokens
#!/usr/bin/env python3.11
# Script for estimating tokens
# Installation: (MacOS)
# - Copy this gist in ~/.local/bin and call it token
# - chmod +x ~/.local/bin/token
# - pip3 install tiktoken
# - echo "hello world"|token
import sys
@ruphy
ruphy / GPT3.js
Last active November 2, 2023 23:41
GPT3() function for Google Sheets
// SPDX-License-Identifier: MIT
//
// This code will add a GPT3() function in your Google Sheets
// This code is originally inspired from https://twitter.com/fabianstelzer/status/1572926883179778050
// To use it, insert your API key below, open Google Sheets -> Extensions -> Apps Script -> Copy & Paste this -> Save
//
// Usage: =GPT3(prompt, max_tokens (default=15), model (default=davinci))
// Example usage: =GPT3("Once upon a time,", 1000, "davinci")
var API_KEY = "your-API-key";

Keybase proof

I hereby claim:

  • I am ruphy on github.
  • I am ruphy (https://keybase.io/ruphy) on keybase.
  • I have a public key ASAoPi10JGGW2yu680FppL7Y38twVRzXWTPv9UyphiaIkAo

To claim this, I am signing this object:

#!/usr/bin/env ruby
$first="75ae56f7ffbc5be14e532e004314e421213107cc"
list = String.new(`git rev-list --first-parent #{$first}..HEAD`)
a = Array.new()
list.scan(/\w+/) { |s|
We couldn’t find that file to show.
m km 1 v