Skip to content

Instantly share code, notes, and snippets.

@bkw777
bkw777 / bashcat.sh
Last active July 23, 2025 17:13
cat without cat
# minimal example just for reference, not pointful by itself
# binary-safe read/write file without cp/cat/dd etc, pure bash, no subshell
while LANG=C IFS= read -d '' -r -n 1 x ;do printf '%c' "$x" ;done <bin1 >bin2
@kickingvegas
kickingvegas / cc-org-table-to-sql.org
Last active June 7, 2024 02:21
Org Code Block cc/org-table-to-sqlite

cc/org-table-to-sqlite

Org Babel code block to import an Org table into an in-memory SQLite DB to enable SQL queries on aforementioned table.

Parameters

  • table : Org table object The Org table object is referenced via the #+NAME value assigned to the table. The table must have a header row identifying each column. This name value must be a SQL-legal name.
  • table-name : string Name of table in string form. It must be identical to the name of the table parameter above.
@thistleknot
thistleknot / rag_quotes.py
Last active November 7, 2024 02:57
RAG quotes
import openai
import os
import sqlite3
import numpy as np
from sklearn.neighbors import NearestNeighbors
from sentence_transformers import SentenceTransformer
from datasets import load_dataset
import pandas as pd
from gptcache import cache
#from gptcache.adapter import openai
@dgicloud
dgicloud / getproxy.py
Created September 11, 2023 14:46
pegar lista de proxy proxyscrape.com
import requests
from requests.exceptions import RequestException
import json
#pegando lista de proxy via api
def proxy_scrap():
url = "https://api.proxyscrape.com/v2/?request=displayproxies&protocol=socks5&timeout=10000&country=all&ssl=yes&anonymity=all"
payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
@wesslen
wesslen / create_data.py
Last active October 17, 2023 03:01
GPT3.5 fine tuning dummy example
import os
import json
import typer
app = typer.Typer()
def process_scripts(input_prompts_file: str, scripts_folder: str, output_file: str):
output_data = []
# Read input prompts from the .jsonl file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@greencamp20552
greencamp20552 / list-model.py
Created July 7, 2023 07:25
gpt4-for-dev-tut
import os
import openai
def init_api():
with open(".env") as env:
for line in env:
key, value = line.strip().split("=")
os.environ[key] = value
openai.api_key = os.environ.get("API_KEY")
@MokoSan
MokoSan / youtube_video_chat.py
Created July 7, 2023 06:57
Chatting with Youtube Videos
from langchain.document_loaders import YoutubeLoader
from langchain.indexes import VectorstoreIndexCreator
loader = YoutubeLoader.from_youtube_url("https://www.youtube.com/watch?v=2v6TpRE82Ps", add_video_info=False)
index = VectorstoreIndexCreator().from_loaders([loader])
query = "What are some top spots to visit in Montepulciano?"
index.query(query)
import re
import uuid
from datetime import datetime
from typing import List, Optional
from pydantic import UUID4, BaseModel, EmailStr, StrictStr, validator
from sqlmodel import Boolean, Column, DateTime, Field, SQLModel
class TimestampsMixin(BaseModel):
from langchain.chat_models import ChatOpenAI
from pydantic import BaseModel, Field
from langchain.document_loaders import UnstructuredURLLoader
from langchain.chains.openai_functions import create_extraction_chain_pydantic
class LLMItem(BaseModel):
title: str = Field(description="The simple and concise title of the product")
description: str = Field(description="The description of the product")
def main():