Skip to content

Instantly share code, notes, and snippets.

View mekarpeles's full-sized avatar
📚
Universal Access to All Knowledge

Mek mekarpeles

📚
Universal Access to All Knowledge
View GitHub Profile

You are an expert book metadata librarian and research assistant. Your role is to produce the most useful, factual, and patron-oriented book metadata possible for the following URL:

You will be given a Book URL


🎯 Overall Behavior Guidelines:

  • ✅ Use both your training knowledge and the full content of the web page at the provided URL to inform your response.
@mekarpeles
mekarpeles / openlibrary_webbook_importer.js
Last active June 27, 2025 20:54
Open Library Web Book Importer Bookmarklet
You are an expert book metadata librarian and research assistant.
Your role is to produce the most useful, factual, and patron-oriented book metadata possible for the following URL:
Book URL: \${url}
---
🎯 Overall Behavior Guidelines:
- ✅ Use both your training knowledge and the full content of the web page at the provided URL to inform your response.
@mekarpeles
mekarpeles / bookdashorg_urls.json
Last active May 27, 2025 14:49
A json list of the books in bookdash.org json
["https://bookdash.org/books/", "https://bookdash.org/books/a-beautiful-day/", "https://bookdash.org/books/siku-ro-saseka/", "https://bookdash.org/books/letsatsi-le-le-botse/", "https://bookdash.org/books/a-fish-and-a-gift/", "https://bookdash.org/books/letsatsi-le-letle-2/", "https://bookdash.org/books/a-dancers-tale/", "https://bookdash.org/books/usuku-oluhle-2/", "https://bookdash.org/books/usuku-oluhle/", "https://bookdash.org/books/tlhapi-le-mpho/", "https://bookdash.org/books/n-vis-en-n-geskenk/", "https://bookdash.org/books/a-house-for-mouse/", "https://bookdash.org/books/intlanzi-kunye-nesipho/", "https://bookdash.org/books/inhlanzi-nesipho/", "https://bookdash.org/books/ntlo-ya-peba/", "https://bookdash.org/books/hlapi-le-mpho/", "https://bookdash.org/books/indlu-kampukwana/", "https://bookdash.org/books/ntlo-bakeng-sa-tweba/", "https://bookdash.org/books/indlu-yagundvwane/", "https://bookdash.org/books/yindlu-ya-nwakondlo/", "https://bookdash.org/books/nn%e1%b8%93u-ya-mbevha/", "https://bookdash.org
@mekarpeles
mekarpeles / thorium_web_recipe.sh
Last active May 1, 2025 12:05
Thorium Web Recipe
cd /tmp
mkdir -p demo
curl -O "https://standardebooks.org/ebooks/l-frank-baum/dorothy-and-the-wizard-in-oz/downloads/l-frank-baum_dorothy-and-the-wizard-in-oz.epub?source=download"
mv l-frank-baum_dorothy-and-the-wizard-in-oz.epub ./demo
docker pull ghcr.io/readium/readium:0.1.0
BOOK=$(echo -n "l-frank-baum_dorothy-and-the-wizard-in-oz.epub" | base64 | tr '/+' '_-' | tr -d '=')
echo "http://localhost:15080/$BOOK/manifest.json"
docker run -d --rm -p 15080:15080 -v ./demo:/srv/publications ghcr.io/readium/readium:0.1.0
curl "http://localhost:15080/$BOOK/manifest.json"
@mekarpeles
mekarpeles / fs-access.js
Created March 2, 2025 20:09
JS File System Access API
<button id="pick-folder">Select Open Library Folder</button>
<ul id="file-list"></ul>
<script type="text/javascript">
async function getStoredDirectory() {
if ("storage" in navigator && "getDirectory" in navigator.storage) {
try {
const dirHandle = await navigator.storage.getDirectory();
return dirHandle.getFileHandle("selected-folder").catch(() => null);
} catch (err) {
@mekarpeles
mekarpeles / process.py
Created February 28, 2025 16:56
A script to flatten Programming Books json
import json
def flatten_books(data):
flat_list = []
def traverse(node, topics):
if "sections" in node:
for section in node["sections"]:
new_topics = topics + [section["section"]]
@mekarpeles
mekarpeles / psql_connections_check.sql
Created January 3, 2025 21:47
Psql Check Connections Recipe
WITH connection_stats AS (
SELECT
state,
COUNT(*) AS count
FROM
pg_stat_activity
GROUP BY
state
),
total_connections AS (
@mekarpeles
mekarpeles / star_ratings_search.diff
Created August 15, 2024 17:47
Adding star ratings info to search page
diff --git a/openlibrary/plugins/worksearch/code.py b/openlibrary/plugins/worksearch/code.py
index be3f4cefe..40d613166 100644
--- a/openlibrary/plugins/worksearch/code.py
+++ b/openlibrary/plugins/worksearch/code.py
@@ -308,8 +308,10 @@ def do_search(
:param sort: csv sort ordering
:param spellcheck_count: Not really used; should probably drop
"""
+ # If you want work_search page html to extend default_fetched_fields:
+ extra_fields = {'editions', 'providers', 'ratings_average', 'ratings_count'}
@mekarpeles
mekarpeles / ol_api_header_example.py
Created May 22, 2024 15:59
python example of adding app identification headers to openlibrary.org API calls
import requests
url = "https://openlibrary.org/search.json?q=test"
headers = {
"User-Agent": "MyAppName/1.0 ([email protected])"
}
response = requests.get(url, headers=headers)
@mekarpeles
mekarpeles / ol_api_header_example.js
Created May 22, 2024 15:58
js example of adding app identification headers to openlibrary.org API calls
const url = "https://openlibrary.org/search.json?q=test";
const headers = new Headers({
"User-Agent": "MyAppName/1.0 ([email protected])"
});
const options = {
method: 'GET',
headers: headers
};
fetch(url, options)
.then(response => response.json())