Skip to content

Instantly share code, notes, and snippets.

View koaning's full-sized avatar

vincent d warmerdam koaning

View GitHub Profile
@koaning
koaning / nb.py
Created October 14, 2024 21:10
tangle-attempt
import anywidget
import traitlets
class TangleWidget(anywidget.AnyWidget):
_esm = """
export default { render };
function render({ model, el }) {
const input = document.createElement('span');
input.style.borderBottom = '1px dashed #3498db';
@koaning
koaning / recipe-names.txt
Created September 14, 2024 13:38
recipe names
pork chop noodle soup
5 ingredient almond cake with fresh berries
shrimp cakes
chili roasted okra
slow cooker chicken chili
fall superfood beef stew
rotisserie turkey breast tenderloin with pesto
j . alexander's mac and cheese
spinach stuffed pork roast
lasagna soup
{
"name": "NuPhy Air60 V2",
"vendorProductId": 435499605,
"macros": [
"{+KC_LSFT}{+KC_LGUI} {-KC_LSFT}{-KC_LGUI}",
"{KC_LGUI} ",
"{+KC_LSFT} ",
"",
"",
"",
@koaning
koaning / recipe.py
Created October 5, 2022 14:18
Custom audio recipe for Prodigy
import prodigy
from typing import List, Optional, Union, Iterable
from prodigy.components.loaders import get_stream
from prodigy.components.preprocess import fetch_media as fetch_media_preprocessor
from prodigy.util import log, msg, get_labels, split_string
from prodigy.types import TaskType, RecipeSettingsType
def remove_base64(examples: List[TaskType]) -> List[TaskType]:
@koaning
koaning / benchmark.py
Last active October 1, 2022 15:08
HTML parsing benchmark
import timeit
import requests
import html_text
import justext
from selectolax.parser import HTMLParser
# There's a difference between these two
html_long = requests.get("http://planet.python.org/").content.decode("utf-8")
html_short = "<p><b>This</b> is just a small example.</p>"
@koaning
koaning / demo.py
Created July 14, 2022 11:45
Demonstration of Operators and Quantifiers from spaCy.
import spacy
from spacy import displacy
def show_results(text, patterns):
nlp = spacy.blank("en")
ruler = nlp.add_pipe("entity_ruler")
ruler.add_patterns(patterns)
doc = nlp(text)
@koaning
koaning / make_patterns.py
Created July 8, 2022 10:02
Scripts that were used in the "Video Games with Sense2Vec" tutorial found here: https://youtu.be/chLZ6g4t3VA.
"""
This script combines two datasets to generate a file with all found patterns.
"""
import srsly
from prodigy.components.db import connect
import spacy
nlp = spacy.blank("en")
@koaning
koaning / recipe.py
Created June 22, 2022 08:35
This is the recipe that belongs to the Prodigy tutorial found on YouTube. https://youtu.be/dXVRonRdg7g
import time
from typing import List
from rich import box
from rich.table import Table
from rich.console import Console
import prodigy
from prodigy.components.loaders import CSV
@koaning
koaning / build_instructions.py
Created June 13, 2022 16:57
Prodigy Instructions
import base64
import pathlib
from jinja2 import Environment, FileSystemLoader, select_autoescape
env = Environment(
loader=FileSystemLoader("images"),
autoescape=select_autoescape()
)
template = env.get_template("instructions.template")
@koaning
koaning / bionic.py
Last active August 11, 2022 14:05
A custom recipe for Prodigy that mimics Bionic Reading.
import pyphen
import prodigy
from prodigy.components.loaders import JSONL
from prodigy.components.db import connect
hyphenator = pyphen.Pyphen(lang="en_US")
def construct_html(text):
hyphend = hyphenator.inserted(text)