- Callbacks = functions you pass into a function so it can notify you about events.
- For LLM streaming, three super-useful callbacks are:
on_start()– called once at the beginningon_token(text: str)– called for each streamed tokenset_status(text: str)– called whenever the function wants to update a status line
- This keeps your LLM logic clean and UI-agnostic while letting your REPL/UI control how things look.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Install the O'Reilly MCP Server on VSCode. You must have your auth token set: | |
| `export OREILLY_API_KEY=xxx` | |
| <a href="https://vscode.dev/redirect/mcp/install?name=oreilly.content-discovery-dev&config=%7B%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fapi.oreilly.review%2Fapi%2Fcontent-discovery%2Fv1%2Fmcp%2F%22%2C%22headers%22%3A%7B%22Authorization%22%3A%22Token%20%24%7BOREILLY_API_KEY%7D%22%7D%7D" rel="nofollow"> | |
| <img src="https://img.shields.io/badge/VS_Code-Install_O%E2%80%99Reilly_MCP-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install O’Reilly MCP"> | |
| </a> | |
| [](https://vscode.dev/redirect/mcp/install?name=oreilly.content-discovery-dev&config=%7B%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fapi.oreilly.review%2Fapi%2Fcontent-discovery%2Fv1%2Fmcp%2F%22%2C%22headers%22%3A%7B%22Authorization%22%3A%22Token%20%24%7BORE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import aiohttp | |
| import sys | |
| import asyncio | |
| import os | |
| # Before you start, get a content token from https://learning.oreilly.com/account/api-tokens/ | |
| # You'll need the account manager role on your user membership. If you're not an account manager | |
| # then you'll need to request on from the U&A team of someone who can create tokens | |
| # Then create an environment variable called ORM_AUTH_TOKEN with the token as the value |
Here's how to import a github repo into drive using google colab.
In the first cell, import the drive package and mount you google drive:
from google.colab import drive
drive.mount('/content/drive')
In the next cell, put a bash script that just clones whatever repo you want:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on https://dev.to/andyrewlee/cheat-sheet-for-updating-objects-and-arrays-in-react-state-48np | |
| const DATA = [ | |
| { id: 123, name: "bart" }, | |
| { id: 256, name: "lisa" }, | |
| { id: 344, name: "homer" }, | |
| { id: 412, name: "marge" }, | |
| ]; | |
| const addRecord = { id: 477, name: "frink" }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # See https://stackoverflow.com/questions/26881441/can-you-get-the-number-of-lines-of-code-from-a-github-repository | |
| # | |
| git clone --depth 1 [email protected]:oreillymedia/heron.git | |
| printf "\nTotal lines\n" | |
| echo "=========================" | |
| cloc heron --quiet --csv --include-lang=Python,JavaScript,HTML --exclude-dir=migrations | cut -d ',' -f 2,5 | |
| printf "\nLines excluding tests\n" | |
| echo "=========================" |
fury is a tool for converting among different API documentation formats
npm install -g fury-cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"swagger": "2.0", "info": {"title": "Discovery Graph API", "description": "", "version": ""}, "host": "web.discovery-graph.svc.dev-seb.local", "schemes": ["https"], "paths": {"/api/graph/discovery/": {"get": {"operationId": "list", "responses": {"200": {"description": ""}}, "parameters": [], "description": "Discovery view to generate REST API schema", "summary": "Discovery view to generate REST API schema", "tags": ["discovery"]}}, "/api/graph/v1/classifier/classify": {"post": {"operationId": "classifier_classify_create", "responses": {"201": {"description": ""}}, "parameters": [{"name": "data", "in": "body", "schema": {"type": "object", "properties": {"identifier": {"description": "", "type": "string"}, "title": {"description": "", "type": "string"}, "description": {"description": "", "type": "string"}}}}], "consumes": ["application/json"], "tags": ["v1"]}}, "/api/graph/v2/content/": {"get": {"operationId": "content_list", "responses": {"200": {"description": ""}}, "parameters": [{"name": "limit", "required |
This is based on:
Also, you have to have a paid plan for this to work. I have the cheapo $7/mo plan.
NewerOlder